possible fix for shards being restarted when bot is starting up

This commit is contained in:
Master Kwoth 2017-10-24 09:19:28 +02:00
parent c21145563f
commit 08fc1b12f7

View File

@ -241,6 +241,7 @@ namespace NadekoBot.Core.Services
await tsc.Task.ConfigureAwait(false); await tsc.Task.ConfigureAwait(false);
while (true) while (true)
{ {
await Task.Delay(10000).ConfigureAwait(false);
try try
{ {
var db = _redis.GetDatabase(); var db = _redis.GetDatabase();
@ -252,13 +253,16 @@ namespace NadekoBot.Core.Services
if (!statuses.Any()) if (!statuses.Any())
{ {
#if !DEBUG #if DEBUG
for (var i = 0; i < _shardProcesses.Length; i++) for (var i = 0; i < _shardProcesses.Length; i++)
{ {
var p = _shardProcesses[i]; var p = _shardProcesses[i];
if (p == null || p.HasExited) if (p == null || p.HasExited)
{
_log.Warn("Scheduling shard {0} for restart because it's process is stopped.", i);
_shardStartQueue.Enqueue(i); _shardStartQueue.Enqueue(i);
} }
}
#endif #endif
} }
else else
@ -277,10 +281,6 @@ namespace NadekoBot.Core.Services
} }
} }
catch (Exception ex) { _log.Error(ex); throw; } catch (Exception ex) { _log.Error(ex); throw; }
finally
{
await Task.Delay(10000).ConfigureAwait(false);
}
} }
}); });