diff --git a/BedrockService/Service/Program.cs b/BedrockService/Service/Program.cs index 478d2478..a4b803a3 100644 --- a/BedrockService/Service/Program.cs +++ b/BedrockService/Service/Program.cs @@ -20,7 +20,7 @@ class Program static void Main(string[] args) { - if (args.Length == 0 && Environment.UserInteractive) + if (args.Length == 0 || Environment.UserInteractive) { IsConsoleMode = true; InstanceProvider.ServiceLogger.AppendLine("BedrockService startup detected in Console mode."); @@ -28,18 +28,16 @@ static void Main(string[] args) else { InstanceProvider.ServiceLogger.AppendLine("BedrockService startup detected in Service mode."); - - foreach (Process process in Process.GetProcesses()) - { - if (process.Id != ServicePID && process.ProcessName.StartsWith("BedrockService.") && process.ProcessName != "BedrockService.Client") + foreach (Process process in Process.GetProcesses()) { - InstanceProvider.ServiceLogger.AppendLine($"Found additional running instance of {process.ProcessName} with ID {process.Id}"); - InstanceProvider.ServiceLogger.AppendLine($"Killing process with id {process.Id}"); - process.Kill(); + if (process.Id != ServicePID && process.ProcessName.StartsWith("BedrockService.") && process.ProcessName != "BedrockService.Client") + { + InstanceProvider.ServiceLogger.AppendLine($"Found additional running instance of {process.ProcessName} with ID {process.Id}"); + InstanceProvider.ServiceLogger.AppendLine($"Killing process with id {process.Id}"); + process.Kill(); + } } - } } - Host host = HostFactory.New(x => { x.SetStartTimeout(TimeSpan.FromSeconds(10)); @@ -77,7 +75,7 @@ static void Main(string[] args) x.OnException((ex) => { - InstanceProvider.ServiceLogger.AppendLine("Exception occured Main : " + ex.ToString()); + InstanceProvider.ServiceLogger.AppendLine("Exception occured Main : " + ex.Message); }); });