From 25e6f278544c946a1460720d4b60994a5a267471 Mon Sep 17 00:00:00 2001 From: John Gross Date: Fri, 17 Nov 2017 12:11:11 -0800 Subject: [PATCH] Fixes for 2017-11-17 major --- Torch.Server/Initializer.cs | 10 ++++++---- Torch.Server/TorchServer.cs | 2 ++ Torch/TorchBase.cs | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Torch.Server/Initializer.cs b/Torch.Server/Initializer.cs index d69feba..7400c54 100644 --- a/Torch.Server/Initializer.cs +++ b/Torch.Server/Initializer.cs @@ -45,7 +45,9 @@ quit"; if (_init) return false; +#if !DEBUG AppDomain.CurrentDomain.UnhandledException += HandleException; +#endif if (!args.Contains("-noupdate")) RunSteamCmd(); @@ -61,11 +63,11 @@ quit"; var pid = int.Parse(_config.WaitForPID); var waitProc = Process.GetProcessById(pid); Log.Info("Continuing in 5 seconds."); - Thread.Sleep(5000); - if (!waitProc.HasExited) + Log.Warn($"Waiting for process {pid} to close"); + while (!waitProc.HasExited) { - Log.Warn($"Killing old process {pid}."); - waitProc.Kill(); + Console.Write("."); + Thread.Sleep(1000); } } diff --git a/Torch.Server/TorchServer.cs b/Torch.Server/TorchServer.cs index 502d94b..3d2eaf5 100644 --- a/Torch.Server/TorchServer.cs +++ b/Torch.Server/TorchServer.cs @@ -163,6 +163,7 @@ namespace Torch.Server Log.Info("Starting server."); MySandboxGame.IsDedicated = true; + MySandboxGame.ConfigDedicated = DedicatedInstance.DedicatedConfig.Model; Environment.SetEnvironmentVariable("SteamAppId", MyPerServerSettings.AppId.ToString()); VRage.Service.ExitListenerSTA.OnExit += delegate { MySandboxGame.Static?.Exit(); }; @@ -309,6 +310,7 @@ namespace Torch.Server var exe = Assembly.GetExecutingAssembly().Location; ((TorchConfig)Config).WaitForPID = Process.GetCurrentProcess().Id.ToString(); Process.Start(exe, Config.ToString()); + Stop(); Environment.Exit(0); } diff --git a/Torch/TorchBase.cs b/Torch/TorchBase.cs index 688e49a..013879d 100644 --- a/Torch/TorchBase.cs +++ b/Torch/TorchBase.cs @@ -193,7 +193,7 @@ namespace Torch /// public void Invoke(Action action) { - MySandboxGame.Static.Invoke(action); + MySandboxGame.Static.Invoke(action, "Torch"); } /// @@ -240,7 +240,7 @@ namespace Torch { e.Set(); } - }); + }, "Torch"); if (!e.WaitOne(60000)) throw new TimeoutException("The game action timed out.");