Shutdown gracefully when recieving a termination signal

This commit is contained in:
Bond_009 2019-01-12 23:31:45 +01:00
parent 78a5d999f4
commit 0abdfbb526

View File

@ -6,6 +6,7 @@ using System.Net;
using System.Net.Security;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.Loader;
using System.Threading.Tasks;
using Emby.Drawing;
using Emby.Drawing.Skia;
@ -55,6 +56,13 @@ namespace Jellyfin.Server
AppDomain.CurrentDomain.UnhandledException += (sender, e)
=> _logger.LogCritical((Exception)e.ExceptionObject, "Unhandled Exception");
// Register a SIGTERM handler
AppDomain.CurrentDomain.ProcessExit += (sender, e) =>
{
_logger.LogInformation("Received a SIGTERM signal, shutting down");
Shutdown();
};
_logger.LogInformation("Jellyfin version: {Version}", version);
EnvironmentInfo environmentInfo = new EnvironmentInfo(getOperatingSystem());