From: Iain Patterson Date: Thu, 17 Feb 2011 00:05:06 +0000 (+0000) Subject: Read registry before each restart. X-Git-Tag: v2.8~5 X-Git-Url: http://git.iain.cx/?a=commitdiff_plain;h=9ee3804b6f85ded39df177e62ff7f51028686cde;p=nssm.git Read registry before each restart. Read Application, AppDirectory and AppParameters before each restart so a change to any one doesn't require restarting NSSM itself. --- diff --git a/service.cpp b/service.cpp index a90d508..a400ebd 100644 --- a/service.cpp +++ b/service.cpp @@ -198,17 +198,6 @@ void WINAPI service_main(unsigned long argc, char **argv) { return; } - /* Get startup parameters */ - int ret = get_parameters(argv[0], exe, sizeof(exe), flags, sizeof(flags), dir, sizeof(dir)); - if (ret) { - log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_GET_PARAMETERS_FAILED, argv[0], 0); - service_status.dwCurrentState = SERVICE_STOPPED; - /* An accurate, if not particularly helpful, status */ - service_status.dwWin32ExitCode = ERROR_SERVICE_NOT_ACTIVE; - SetServiceStatus(service_handle, &service_status); - return; - } - service_status.dwCurrentState = SERVICE_START_PENDING; service_status.dwWaitHint = NSSM_RESET_THROTTLE_RESTART + NSSM_WAITHINT_MARGIN; SetServiceStatus(service_handle, &service_status); @@ -304,6 +293,13 @@ int start_service() { PROCESS_INFORMATION pi; ZeroMemory(&pi, sizeof(pi)); + /* Get startup parameters */ + int ret = get_parameters(service_name, exe, sizeof(exe), flags, sizeof(flags), dir, sizeof(dir)); + if (ret) { + log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_GET_PARAMETERS_FAILED, service_name, 0); + return stop_service(2, true, true); + } + /* Launch executable with arguments */ char cmd[CMD_LENGTH]; if (_snprintf(cmd, sizeof(cmd), "%s %s", exe, flags) < 0) {