Handle SIGTERM

This commit is contained in:
Nikolay Kochulin 2019-12-07 13:41:26 +00:00
parent 29af7c9183
commit bfc67c4c8f

View File

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