Allow restarting a service.
authorIain Patterson <me@iain.cx>
Mon, 13 Jan 2014 12:11:07 +0000 (12:11 +0000)
committerIain Patterson <me@iain.cx>
Mon, 13 Jan 2014 12:13:26 +0000 (12:13 +0000)
Running "nssm restart <service>" will try to send a stop control
followed by a start control.  It will fail if the service was stopped at
the outset or if it didn't respond to the stop control in a timely
manner.

README.txt
messages.mc
nssm.cpp

index 0affeb3..b05fd78 100644 (file)
@@ -514,6 +514,8 @@ NSSM offers rudimentary service control features.
 \r
     nssm start <servicename>\r
 \r
+    nssm restart <servicename>\r
+\r
     nssm stop <servicename>\r
 \r
     nssm status <servicename>\r
index 30eb165..5bb5adc 100644 (file)
Binary files a/messages.mc and b/messages.mc differ
index 37f3aea..931496a 100644 (file)
--- a/nssm.cpp
+++ b/nssm.cpp
@@ -105,6 +105,11 @@ int _tmain(int argc, TCHAR **argv) {
     */\r
     if (str_equiv(argv[1], _T("start"))) exit(control_service(NSSM_SERVICE_CONTROL_START, argc - 2, argv + 2));\r
     if (str_equiv(argv[1], _T("stop"))) exit(control_service(SERVICE_CONTROL_STOP, argc - 2, argv + 2));\r
+    if (str_equiv(argv[1], _T("restart"))) {\r
+      int ret = control_service(SERVICE_CONTROL_STOP, argc - 2, argv + 2);\r
+      if (ret) exit(ret);\r
+      exit(control_service(NSSM_SERVICE_CONTROL_START, argc - 2, argv + 2));\r
+    }\r
     if (str_equiv(argv[1], _T("pause"))) exit(control_service(SERVICE_CONTROL_PAUSE, argc - 2, argv + 2));\r
     if (str_equiv(argv[1], _T("continue"))) exit(control_service(SERVICE_CONTROL_CONTINUE, argc - 2, argv + 2));\r
     if (str_equiv(argv[1], _T("status"))) exit(control_service(SERVICE_CONTROL_INTERROGATE, argc - 2, argv + 2));\r