-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -438,6 +438,34 @@ public void LogMessage<TState>(string categoryName, LogLevel logLevel, EventId e | |
} | ||
} | ||
|
||
public void SignalLameDuckMode() | ||
{ | ||
if (ServerProcess == null || ServerProcess.HasExited) | ||
{ | ||
throw new Exception("Cannot signal LDM, server process is not running."); | ||
} | ||
|
||
var signalProcess = new Process | ||
{ | ||
StartInfo = new ProcessStartInfo | ||
Check warning on line 450 in tests/NATS.Client.TestUtilities/NatsServer.cs GitHub Actions / Windows (v2.9)
Check warning on line 450 in tests/NATS.Client.TestUtilities/NatsServer.cs GitHub Actions / Windows (v2.9)
Check warning on line 450 in tests/NATS.Client.TestUtilities/NatsServer.cs GitHub Actions / Windows (v2.9)
Check warning on line 450 in tests/NATS.Client.TestUtilities/NatsServer.cs GitHub Actions / Windows (v2.9)
Check warning on line 450 in tests/NATS.Client.TestUtilities/NatsServer.cs GitHub Actions / test (v2.9)
Check warning on line 450 in tests/NATS.Client.TestUtilities/NatsServer.cs GitHub Actions / test (v2.9)
Check warning on line 450 in tests/NATS.Client.TestUtilities/NatsServer.cs GitHub Actions / check
Check warning on line 450 in tests/NATS.Client.TestUtilities/NatsServer.cs GitHub Actions / check
Check warning on line 450 in tests/NATS.Client.TestUtilities/NatsServer.cs GitHub Actions / Linux (v2.9)
Check warning on line 450 in tests/NATS.Client.TestUtilities/NatsServer.cs GitHub Actions / Linux (v2.9)
Check warning on line 450 in tests/NATS.Client.TestUtilities/NatsServer.cs GitHub Actions / Linux (v2.9)
Check warning on line 450 in tests/NATS.Client.TestUtilities/NatsServer.cs GitHub Actions / Linux (v2.9)
Check warning on line 450 in tests/NATS.Client.TestUtilities/NatsServer.cs GitHub Actions / test (latest)
Check warning on line 450 in tests/NATS.Client.TestUtilities/NatsServer.cs GitHub Actions / test (latest)
Check warning on line 450 in tests/NATS.Client.TestUtilities/NatsServer.cs GitHub Actions / Windows (latest)
Check warning on line 450 in tests/NATS.Client.TestUtilities/NatsServer.cs GitHub Actions / Windows (latest)
Check warning on line 450 in tests/NATS.Client.TestUtilities/NatsServer.cs GitHub Actions / Windows (latest)
Check warning on line 450 in tests/NATS.Client.TestUtilities/NatsServer.cs GitHub Actions / Windows (latest)
Check warning on line 450 in tests/NATS.Client.TestUtilities/NatsServer.cs GitHub Actions / test (main)
Check warning on line 450 in tests/NATS.Client.TestUtilities/NatsServer.cs GitHub Actions / test (main)
Check warning on line 450 in tests/NATS.Client.TestUtilities/NatsServer.cs GitHub Actions / Linux (latest)
Check warning on line 450 in tests/NATS.Client.TestUtilities/NatsServer.cs GitHub Actions / Linux (latest)
Check warning on line 450 in tests/NATS.Client.TestUtilities/NatsServer.cs GitHub Actions / Linux (latest)
Check warning on line 450 in tests/NATS.Client.TestUtilities/NatsServer.cs GitHub Actions / Linux (latest)
Check warning on line 450 in tests/NATS.Client.TestUtilities/NatsServer.cs GitHub Actions / Windows (main)
Check warning on line 450 in tests/NATS.Client.TestUtilities/NatsServer.cs GitHub Actions / Windows (main)
Check warning on line 450 in tests/NATS.Client.TestUtilities/NatsServer.cs GitHub Actions / Windows (main)
Check warning on line 450 in tests/NATS.Client.TestUtilities/NatsServer.cs GitHub Actions / Windows (main)
Check warning on line 450 in tests/NATS.Client.TestUtilities/NatsServer.cs GitHub Actions / Linux (main)
Check warning on line 450 in tests/NATS.Client.TestUtilities/NatsServer.cs GitHub Actions / Linux (main)
Check warning on line 450 in tests/NATS.Client.TestUtilities/NatsServer.cs GitHub Actions / Linux (main)
Check warning on line 450 in tests/NATS.Client.TestUtilities/NatsServer.cs GitHub Actions / Linux (main)
|
||
{ | ||
FileName = NatsServerPath, | ||
Arguments = $"--signal ldm={ServerProcess.Id}", | ||
RedirectStandardOutput = true, | ||
UseShellExecute = false, | ||
} | ||
}; | ||
|
||
signalProcess.Start(); | ||
signalProcess.WaitForExit(); | ||
|
||
if (signalProcess.ExitCode != 0) | ||
{ | ||
var error = signalProcess.StandardError.ReadToEnd(); | ||
throw new Exception($"Failed to signal lame duck mode: {error}"); | ||
} | ||
} | ||
|
||
private static (string configFileName, string config, string cmd) GetCmd(NatsServerOpts opts) | ||
{ | ||
var configFileName = Path.GetTempFileName(); | ||
|