diff --git a/Projects/Server/Main.cs b/Projects/Server/Main.cs index d3d12556e..6955d647a 100644 --- a/Projects/Server/Main.cs +++ b/Projects/Server/Main.cs @@ -36,6 +36,8 @@ public static class Core { private static readonly ILogger logger = LogFactory.GetLogger(typeof(Core)); + private static bool _performProcessKill; + private static bool _restartOnKill; private static bool _performSnapshot; private static bool _crashed; private static string _baseDirectory; @@ -304,6 +306,12 @@ public static class Core } } + public static void Kill(bool restart = false) + { + _performProcessKill = true; + _restartOnKill = restart; + } + private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { Console.WriteLine(e.IsTerminating ? "Error:" : "Warning:"); @@ -359,7 +367,7 @@ public static class Core Kill(); } - public static void Kill(bool restart = false) + internal static void DoKill(bool restart = false) { if (Closing) { @@ -569,6 +577,11 @@ public static class Core World.Snapshot(); } + if (_performProcessKill) + { + DoKill(_restartOnKill); + } + _tickCount = 0; _now = DateTime.MinValue;