From 29fcdc0bf8a1909f3d9a9014c86d88d612c703ce Mon Sep 17 00:00:00 2001 From: Brant Martin Date: Wed, 22 Apr 2020 15:31:55 -0400 Subject: [PATCH] Add temporary autostart flag for restart commands and autostart commandline switch (#382) Co-authored-by: Jimmacle --- Torch.Server/Initializer.cs | 7 +++++-- Torch.Server/TorchConfig.cs | 11 +++++++++-- Torch.Server/TorchServer.cs | 2 +- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Torch.Server/Initializer.cs b/Torch.Server/Initializer.cs index ab1a920..e13aaf0 100644 --- a/Torch.Server/Initializer.cs +++ b/Torch.Server/Initializer.cs @@ -144,9 +144,12 @@ quit"; var gameThread = new Thread(() => { _server.Init(); - - if (_config.Autostart) + + if (_config.Autostart || _config.TempAutostart) + { + _config.TempAutostart = false; _server.Start(); + } }); gameThread.Start(); diff --git a/Torch.Server/TorchConfig.cs b/Torch.Server/TorchConfig.cs index 4223532..f1a6ab7 100644 --- a/Torch.Server/TorchConfig.cs +++ b/Torch.Server/TorchConfig.cs @@ -62,10 +62,17 @@ namespace Torch.Server [XmlIgnore, Arg("forceupdate", "Manually check for and install updates.")] public bool ForceUpdate { get; set; } - /// - [Arg("autostart", "Start the server immediately.")] + /// + /// Permanent flag to ALWAYS automatically start the server + /// public bool Autostart { get; set; } + /// + /// Temporary flag to automatically start the server only on the next run + /// + [Arg("autostart", "Start the server immediately.")] + public bool TempAutostart { get; set; } + /// [Arg("restartoncrash", "Automatically restart the server if it crashes.")] public bool RestartOnCrash { get; set; } diff --git a/Torch.Server/TorchServer.cs b/Torch.Server/TorchServer.cs index fdd8952..72235f9 100644 --- a/Torch.Server/TorchServer.cs +++ b/Torch.Server/TorchServer.cs @@ -212,7 +212,7 @@ namespace Torch.Server string exe = Assembly.GetExecutingAssembly().Location; Debug.Assert(exe != null); config.WaitForPID = Process.GetCurrentProcess().Id.ToString(); - config.Autostart = true; + config.TempAutostart = true; Process.Start(exe, config.ToString()); Process.GetCurrentProcess().Kill();