Handle SIGTERM

This commit is contained in:
Basique Evangelist 2019-12-07 13:41:26 +00:00
parent 8132f8edac
commit 228c078947
Signed by untrusted user: BasiqueEvangelist
GPG Key ID: B370219149301706

View File

@ -1,4 +1,6 @@
using System; using System;
using System.Reflection;
using System.Runtime.Loader;
using System.Threading; using System.Threading;
using JetKarmaBot.Models; using JetKarmaBot.Models;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
@ -57,6 +59,11 @@ namespace JetKarmaBot
eArgs.Cancel = true; eArgs.Cancel = true;
quitEvent.Set(); quitEvent.Set();
}; };
AppDomain.CurrentDomain.ProcessExit += (sender, args) =>
{
log.Info("Received stop request, waiting for exit...");
bot?.Stop()?.Wait();
};
} }
catch { } catch { }