From 23bed76e3a4b8a407a58ec8e1422de90fc750ab3 Mon Sep 17 00:00:00 2001 From: Iain Patterson Date: Mon, 13 Jan 2014 12:11:07 +0000 Subject: [PATCH] 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. --- README.txt | 2 ++ messages.mc | Bin 143950 -> 144166 bytes nssm.cpp | 5 +++++ 3 files changed, 7 insertions(+) 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 30eb165ca56bf15fcf6d43fb360639b0935ba3d7..5bb5adc1a9412ceeff60fb1d909f50b5e151b09a 100644 GIT binary patch delta 75 zcmX^2gk#w=jt%G7r-v9b3QRsDW;5AKykPPPEtSn_9A0Rm9$z&!`w0AEgR5=!5^whs MXWZ^3&cq@O092A1WB>pF delta 48 zcmZ4XjN{xBjt%G7Cp!pqZC=0;!M@o+U>b;5GWkS!)Z}&22F)^(?J|;#+hrt~xTFB= C5)lyq 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)); -- 2.20.1