Improve resource server initialization and mutex handling

Adds a null check for the resource server after initialization and logs an error if it fails. Changes duplicate launcher instance log from error to info, and wraps mutex release in a try-catch to prevent exceptions if not owned.
This commit is contained in:
Namhyeon Go 2025-08-26 13:02:32 +09:00
parent f3db44d8e3
commit e9d475ba4c
2 changed files with 10 additions and 2 deletions

View File

@ -177,6 +177,12 @@ namespace WelsonJS.Launcher
{
Program.InitializeResourceServer();
if (Program._resourceServer == null)
{
_logger.Error("Resource server failed to initialize.");
return false;
}
if (!Program._resourceServer.IsRunning())
{
Program._resourceServer.Start(false);

View File

@ -32,7 +32,7 @@ namespace WelsonJS.Launcher
_mutex = new Mutex(true, "WelsonJS.Launcher", out bool createdNew);
if (!createdNew)
{
_logger.Error("WelsonJS Launcher already running.");
_logger.Info("WelsonJS Launcher already running.");
return;
}
@ -42,7 +42,9 @@ namespace WelsonJS.Launcher
Application.Run(new MainForm(_logger));
// destory the mutex
try {
_mutex.ReleaseMutex();
} catch { /* ignore if not owned */ }
_mutex.Dispose();
}