From e9d475ba4ced284351c63acc5dc3e6b8ee8795f9 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Tue, 26 Aug 2025 13:02:32 +0900 Subject: [PATCH] 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. --- WelsonJS.Toolkit/WelsonJS.Launcher/MainForm.cs | 6 ++++++ WelsonJS.Toolkit/WelsonJS.Launcher/Program.cs | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/WelsonJS.Toolkit/WelsonJS.Launcher/MainForm.cs b/WelsonJS.Toolkit/WelsonJS.Launcher/MainForm.cs index 80f3c07..6787c99 100644 --- a/WelsonJS.Toolkit/WelsonJS.Launcher/MainForm.cs +++ b/WelsonJS.Toolkit/WelsonJS.Launcher/MainForm.cs @@ -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); diff --git a/WelsonJS.Toolkit/WelsonJS.Launcher/Program.cs b/WelsonJS.Toolkit/WelsonJS.Launcher/Program.cs index 9ff1efe..23547c6 100644 --- a/WelsonJS.Toolkit/WelsonJS.Launcher/Program.cs +++ b/WelsonJS.Toolkit/WelsonJS.Launcher/Program.cs @@ -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 - _mutex.ReleaseMutex(); + try { + _mutex.ReleaseMutex(); + } catch { /* ignore if not owned */ } _mutex.Dispose(); }