aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Program.cs
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2025-12-13 17:15:16 -0600
committerJP Dillingham <jp@dillingham.me>2025-12-13 17:15:16 -0600
commite08479ee8d91952fee13b009f861912a92a2dbae (patch)
tree1895a8168b89f27358ede8e13107de6d6182d516 /src/slskd/Program.cs
parent4792270460293b4810e2e2a34f8deede39008502 (diff)
downloadslskd-e08479ee8d91952fee13b009f861912a92a2dbae.tar.gz
tweak
Diffstat (limited to 'src/slskd/Program.cs')
-rw-r--r--src/slskd/Program.cs25
1 files changed, 9 insertions, 16 deletions
diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs
index 3bd0798b..db4f7c6c 100644
--- a/src/slskd/Program.cs
+++ b/src/slskd/Program.cs
@@ -23,8 +23,6 @@ namespace slskd
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
- using System.Diagnostics;
-
using System.IO;
using System.Linq;
using System.Net;
@@ -337,10 +335,9 @@ namespace slskd
// only one long-running instance.
try
{
- bool createdNew;
- Mutex = new Mutex(initiallyOwned: true, Compute.Sha256Hash(AppName), out createdNew);
+ Mutex = new Mutex(initiallyOwned: true, Compute.Sha256Hash(AppName), out bool created);
- if (!createdNew)
+ if (!created)
{
Log.Fatal($"An instance of {AppName} is already running");
return;
@@ -348,22 +345,18 @@ namespace slskd
}
catch (IOException ex)
{
- Log.Warning($"Failed to acquire the application singleton mutex: {ex.Message}");
- Log.Warning("This can happen when running in a restricted environment (e.g., Kubernetes with readOnlyRootFilesystem)");
- Log.Warning("The application will continue, but multiple instances may be able to run simultaneously");
+ Log.Fatal($"I/O exception attempting to acquire the application singleton mutex; this can happen when running in a restricted environment (such as a read-only filesystem or container). Exception: {ex.Message}");
+ return;
}
catch (UnauthorizedAccessException ex)
{
- Log.Warning($"Failed to acquire the application singleton mutex: {ex.Message}");
- Log.Warning("This can happen when running with insufficient permissions");
- Log.Warning("The application will continue, but multiple instances may be able to run simultaneously");
+ Log.Fatal($"Unauthorized access attempting to acquire the application singleton mutex; this can happen when running with insuffucent permissions. Exception: {ex.Message}");
+ return;
}
- catch (AbandonedMutexException ex)
+ catch (Exception ex)
{
- Log.Warning($"Acquired an abandoned mutex: {ex.Message}");
- Log.Warning("A previous instance may have terminated unexpectedly");
-
- // The mutex is now owned by this thread, so we can continue
+ Log.Fatal($"Failed to acquire the application singleton mutex: {ex.Message}");
+ return;
}
// derive the application directory value and defaults that are dependent upon it