/* Initialise status */\r
ZeroMemory(&service_status, sizeof(service_status));\r
service_status.dwServiceType = SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS;\r
- service_status.dwCurrentState = SERVICE_RUNNING;\r
service_status.dwControlsAccepted = SERVICE_ACCEPT_SHUTDOWN | SERVICE_ACCEPT_STOP;\r
service_status.dwWin32ExitCode = NO_ERROR;\r
service_status.dwServiceSpecificExitCode = 0;\r
/* Signal we AREN'T running the server */\r
pid = 0;\r
\r
+ /* Register control handler */\r
+ service_handle = RegisterServiceCtrlHandlerEx(NSSM, service_control_handler, 0);\r
+ if (! service_handle) {\r
+ log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_REGISTERSERVICECTRLHANDER_FAILED, GetLastError(), 0);\r
+ return;\r
+ }\r
+\r
/* Get startup parameters */\r
int ret = get_parameters(argv[0], exe, sizeof(exe), flags, sizeof(flags), dir, sizeof(dir));\r
if (ret) {\r
log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_GET_PARAMETERS_FAILED, argv[0], 0);\r
+ service_status.dwCurrentState = SERVICE_STOPPED;\r
+ /* An accurate, if not particularly helpful, status */\r
+ service_status.dwWin32ExitCode = ERROR_SERVICE_NOT_ACTIVE;\r
+ SetServiceStatus(service_handle, &service_status);\r
return;\r
}\r
\r
- /* Register control handler */\r
- service_handle = RegisterServiceCtrlHandlerEx(NSSM, service_control_handler, 0);\r
- if (! service_handle) {\r
- log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_REGISTERSERVICECTRLHANDER_FAILED, GetLastError(), 0);\r
- return;\r
- }\r
+ service_status.dwCurrentState = SERVICE_START_PENDING;\r
+ SetServiceStatus(service_handle, &service_status);\r
\r
/* Try to create the exit action parameters; we don't care if it fails */\r
create_exit_action(argv[0], exit_action_strings[0]);\r