From 0c5a47ff9d4041c682ee706318b49802d4756908 Mon Sep 17 00:00:00 2001 From: Sam Weaver Date: Tue, 11 Jan 2022 19:34:41 -0500 Subject: [PATCH] Allow the server to shutdown before the main loop has started --- Robust.Server/BaseServer.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Robust.Server/BaseServer.cs b/Robust.Server/BaseServer.cs index 7e0212f9b..818c58b1e 100644 --- a/Robust.Server/BaseServer.cs +++ b/Robust.Server/BaseServer.cs @@ -127,7 +127,7 @@ namespace Robust.Server _shutdownReason = reason; - _mainLoop.Running = false; + if (_mainLoop != null) _mainLoop.Running = false; if (_logHandler != null) { _log.RootSawmill.RemoveHandler(_logHandler); @@ -506,7 +506,13 @@ namespace Robust.Server { SetupMainLoop(); - _mainLoop.Run(); + // If the server has been given a reason to shut down before the main loop has started, + // Don't start the main loop. This only works if a reason is passed to Shutdown(...) + if (_shutdownReason != null) + { + Logger.Fatal("Shutdown has been requested before the main loop has been started, complying."); + } + else _mainLoop.Run(); FinishMainLoop(); }