Merge pull request #442 from tgstation/437-HandleDeadOnArrival

Fix watchdog crashing if DreamDaemon immediately exits
This commit is contained in:
Jordan Brown
2017-12-06 13:02:50 -05:00
committed by GitHub
+7 -3
View File
@@ -346,8 +346,12 @@ namespace TGS.Server
CurrentDDLog = DateTime.UtcNow.ToString("yyyy-MM-ddTHH-mm-ssZ");
WriteCurrentDDLog("Starting monitoring...");
}
pcpu = new PerformanceCounter("Process", "% Processor Time", Proc.ProcessName, true);
MemTrackTimer.Start();
try
{
pcpu = new PerformanceCounter("Process", "% Processor Time", Proc.ProcessName, true);
MemTrackTimer.Start();
}
catch (InvalidOperationException) { /*process already exited*/ }
try
{
Proc.WaitForExit();
@@ -357,7 +361,7 @@ namespace TGS.Server
lock (watchdogLock) //synchronize
{
MemTrackTimer.Stop();
pcpu.Dispose();
pcpu?.Dispose();
}
}