diff --git a/App/Services/MutagenController.cs b/App/Services/MutagenController.cs index 3931b66..eba0952 100644 --- a/App/Services/MutagenController.cs +++ b/App/Services/MutagenController.cs @@ -441,6 +441,7 @@ private async Task UpdateState(MutagenClient cl /// private async Task EnsureDaemon(CancellationToken ct) { + _logger.LogDebug("EnsureDaemon called"); ObjectDisposedException.ThrowIf(_disposing, typeof(MutagenController)); if (_mutagenClient != null && _daemonProcess != null) return _mutagenClient; @@ -479,12 +480,14 @@ private async Task EnsureDaemon(CancellationToken ct) /// private async Task StartDaemon(CancellationToken ct) { + _logger.LogDebug("StartDaemon called"); // Stop the running daemon if (_daemonProcess != null) await StopDaemon(ct); // Attempt to stop any orphaned daemon try { + _logger.LogDebug("creating MutagenClient to stop orphan"); var client = new MutagenClient(_mutagenDataDirectory); await client.Daemon.TerminateAsync(new DaemonTerminateRequest(), cancellationToken: ct); } @@ -496,6 +499,10 @@ private async Task StartDaemon(CancellationToken ct) { // Mainline; no daemon running. } + finally + { + _logger.LogDebug("finished with orphan mutagen client"); + } // If we get some failure while creating the log file or starting the process, we'll retry // it up to 5 times x 100ms. Those issues should resolve themselves quickly if they are @@ -528,6 +535,7 @@ private async Task StartDaemon(CancellationToken ct) ct.ThrowIfCancellationRequested(); try { + _logger.LogDebug("creating mainline mutagen client"); var client = new MutagenClient(_mutagenDataDirectory); _ = await client.Daemon.VersionAsync(new VersionRequest(), cancellationToken: ct); _mutagenClient = client; diff --git a/MutagenSdk/MutagenClient.cs b/MutagenSdk/MutagenClient.cs index 27ffa7a..89fad29 100644 --- a/MutagenSdk/MutagenClient.cs +++ b/MutagenSdk/MutagenClient.cs @@ -16,26 +16,6 @@ public class MutagenClient : IDisposable public MutagenClient(string dataDir) { - // Check for the lock file first, since it should exist if it's running. - var daemonLockFile = Path.Combine(dataDir, "daemon", "daemon.lock"); - if (!File.Exists(daemonLockFile)) - throw new FileNotFoundException( - "Mutagen daemon lock file not found, did the mutagen daemon start successfully?", daemonLockFile); - - // We should not be able to open the lock file. - try - { - using var _ = File.Open(daemonLockFile, FileMode.Open, FileAccess.Write, FileShare.None); - // We throw a FileNotFoundException if we could open the file because - // it means the same thing and allows us to return the path nicely. - throw new InvalidOperationException( - $"Mutagen daemon lock file '{daemonLockFile}' is unlocked, did the mutagen daemon start successfully?"); - } - catch (IOException) - { - // this is what we expect - } - // Read the IPC named pipe address from the sock file. var daemonSockFile = Path.Combine(dataDir, "daemon", "daemon.sock"); if (!File.Exists(daemonSockFile))