Add stopwait command

pull/341/head
Michael Karmazin 2019-10-17 11:21:08 +11:00 committed by NextTurn
parent b0c09e1bb1
commit a8fee1975f
No known key found for this signature in database
GPG Key ID: 17A0D50ADDE1A0C4
1 changed files with 24 additions and 0 deletions

View File

@ -607,6 +607,10 @@ namespace winsw
Stop(); Stop();
return; return;
case "stopwait":
StopWait();
return;
case "restart": case "restart":
Restart(); Restart();
return; return;
@ -815,6 +819,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()
{ {
Log.Info("Restarting the service with id '" + descriptor.Id + "'"); Log.Info("Restarting the service with id '" + descriptor.Id + "'");
@ -984,6 +1007,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