From: Iain Patterson Date: Mon, 13 Jan 2014 12:11:07 +0000 (+0000) Subject: Allow restarting a service. X-Git-Tag: v2.22~58 X-Git-Url: http://git.iain.cx/?a=commitdiff_plain;h=23bed76e3a4b8a407a58ec8e1422de90fc750ab3;p=nssm.git Allow restarting a service. Running "nssm restart " 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. --- diff --git a/README.txt b/README.txt index 0affeb3..b05fd78 100644 --- a/README.txt +++ b/README.txt @@ -514,6 +514,8 @@ NSSM offers rudimentary service control features. nssm start + nssm restart + nssm stop nssm status diff --git a/messages.mc b/messages.mc index 30eb165..5bb5adc 100644 Binary files a/messages.mc and b/messages.mc differ diff --git a/nssm.cpp b/nssm.cpp index 37f3aea..931496a 100644 --- a/nssm.cpp +++ b/nssm.cpp @@ -105,6 +105,11 @@ int _tmain(int argc, TCHAR **argv) { */ if (str_equiv(argv[1], _T("start"))) exit(control_service(NSSM_SERVICE_CONTROL_START, argc - 2, argv + 2)); if (str_equiv(argv[1], _T("stop"))) exit(control_service(SERVICE_CONTROL_STOP, argc - 2, argv + 2)); + if (str_equiv(argv[1], _T("restart"))) { + int ret = control_service(SERVICE_CONTROL_STOP, argc - 2, argv + 2); + if (ret) exit(ret); + exit(control_service(NSSM_SERVICE_CONTROL_START, argc - 2, argv + 2)); + } if (str_equiv(argv[1], _T("pause"))) exit(control_service(SERVICE_CONTROL_PAUSE, argc - 2, argv + 2)); if (str_equiv(argv[1], _T("continue"))) exit(control_service(SERVICE_CONTROL_CONTINUE, argc - 2, argv + 2)); if (str_equiv(argv[1], _T("status"))) exit(control_service(SERVICE_CONTROL_INTERROGATE, argc - 2, argv + 2));