Handle complete discord outage

This commit is contained in:
13xforever 2019-05-04 21:53:10 +05:00
parent 92c1db42e5
commit d2df3c5961
2 changed files with 7 additions and 14 deletions

View File

@ -128,6 +128,7 @@ namespace CompatBot.Commands
internal static void Restart(ulong channelId)
{
Config.Log.Info("Restarting...");
using (var self = new Process
{
#if DEBUG

View File

@ -219,17 +219,7 @@ namespace CompatBot
}
logLevel(eventArgs.Exception, eventArgs.Message);
};
try
{
await client.ConnectAsync();
}
catch (Exception e)
{
Config.Log.Fatal(e, "Terminating");
return;
}
await client.ConnectAsync();
if (args.Length > 1 && ulong.TryParse(args[1], out var channelId))
{
Config.Log.Info($"Found channelId: {args[1]}");
@ -262,8 +252,11 @@ namespace CompatBot
}
await backgroundTasks.ConfigureAwait(false);
}
catch (TaskCanceledException) { }
catch(Exception e)
catch (TaskCanceledException)
{
Config.Log.Info("Exiting");
}
catch (Exception e)
{
Config.Log.Fatal(e, "Experienced catastrophic failure, attempting to restart...");
Sudo.Bot.Restart(InvalidChannelId);
@ -273,7 +266,6 @@ namespace CompatBot
ShutdownCheck.Release();
if (singleInstanceCheckThread.IsAlive)
singleInstanceCheckThread.Join(100);
Config.Log.Info("Exiting");
}
}
}