mirror of https://github.com/winsw/winsw
Merge pull request #341 from new-mikha/master
Add stopwait command - same as stop, but waits until the service is actually stopped:pull/513/head v2.9.0
commit
ee29eee8cf
|
@ -42,6 +42,7 @@ Your renamed *WinSW.exe* binary also accepts the following commands:
|
||||||
* `uninstall` to uninstall the service. The opposite operation of above.
|
* `uninstall` to uninstall the service. The opposite operation of above.
|
||||||
* `start` to start the service. The service must have already been installed.
|
* `start` to start the service. The service must have already been installed.
|
||||||
* `stop` to stop the service.
|
* `stop` to stop the service.
|
||||||
|
* `stopwait` to stop the service and wait until it's actually stopped.
|
||||||
* `restart` to restart the service. If the service is not currently running, this command acts like `start`.
|
* `restart` to restart the service. If the service is not currently running, this command acts like `start`.
|
||||||
* `status` to check the current status of the service.
|
* `status` to check the current status of the service.
|
||||||
* This command prints one line to the console.
|
* This command prints one line to the console.
|
||||||
|
|
|
@ -623,6 +623,10 @@ namespace winsw
|
||||||
Stop();
|
Stop();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
case "stopwait":
|
||||||
|
StopWait();
|
||||||
|
return;
|
||||||
|
|
||||||
case "restart":
|
case "restart":
|
||||||
Restart();
|
Restart();
|
||||||
return;
|
return;
|
||||||
|
@ -861,6 +865,25 @@ namespace winsw
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StopWait()
|
||||||
|
{
|
||||||
|
Log.Info("Stopping the service with id '" + descriptor.Id + "'");
|
||||||
|
if (s is null)
|
||||||
|
ThrowNoSuchService();
|
||||||
|
|
||||||
|
if (s.Started)
|
||||||
|
s.StopService();
|
||||||
|
|
||||||
|
while (s != null && s.Started)
|
||||||
|
{
|
||||||
|
Log.Info("Waiting the service to stop...");
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
s = svc.Select(descriptor.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.Info("The service stopped.");
|
||||||
|
}
|
||||||
|
|
||||||
void Restart()
|
void Restart()
|
||||||
{
|
{
|
||||||
if (!elevated)
|
if (!elevated)
|
||||||
|
@ -1121,6 +1144,7 @@ namespace winsw
|
||||||
uninstall uninstall the service
|
uninstall uninstall the service
|
||||||
start start the service (must be installed before)
|
start start the service (must be installed before)
|
||||||
stop stop the service
|
stop stop the service
|
||||||
|
stopwait stop the service and wait until it's actually stopped
|
||||||
restart restart the service
|
restart restart the service
|
||||||
restart! self-restart (can be called from child processes)
|
restart! self-restart (can be called from child processes)
|
||||||
status check the current status of the service
|
status check the current status of the service
|
||||||
|
|
Loading…
Reference in New Issue