X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=service.cpp;h=9cdf9dedd301246632b5a32252e5d44b33be1d06;hb=0f9817471a5b65eeedf1b4a892e86fb486a55807;hp=1c82a38ae8d4c52c6b50b645e0000277c604b447;hpb=3509063391d4180797926408610608051a8ad626;p=nssm.git diff --git a/service.cpp b/service.cpp index 1c82a38..9cdf9de 100644 --- a/service.cpp +++ b/service.cpp @@ -1213,7 +1213,10 @@ int control_service(unsigned long control, int argc, TCHAR **argv) { } else { CloseHandle(service_handle); - _ftprintf(stderr, _T("%s: %s %s"), canonical_name, service_control_text(control), error_string(error)); + _ftprintf(stderr, _T("%s: %s: %s"), canonical_name, service_control_text(control), error_string(error)); + if (error == ERROR_SERVICE_NOT_ACTIVE) { + if (control == SERVICE_CONTROL_SHUTDOWN || control == SERVICE_CONTROL_STOP) return 0; + } return 1; } } @@ -1473,8 +1476,8 @@ unsigned long WINAPI service_control_handler(unsigned long control, unsigned lon case NSSM_SERVICE_CONTROL_ROTATE: log_service_control(service->name, control, true); - if (service->rotate_stdout_online) service->rotate_stdout_online = NSSM_ROTATE_ONLINE_ASAP; - if (service->rotate_stderr_online) service->rotate_stderr_online = NSSM_ROTATE_ONLINE_ASAP; + if (service->rotate_stdout_online == NSSM_ROTATE_ONLINE) service->rotate_stdout_online = NSSM_ROTATE_ONLINE_ASAP; + if (service->rotate_stderr_online == NSSM_ROTATE_ONLINE) service->rotate_stderr_online = NSSM_ROTATE_ONLINE_ASAP; return NO_ERROR; } @@ -1539,7 +1542,7 @@ int start_service(nssm_service_t *service) { if (get_process_creation_time(service->process_handle, &service->creation_time)) ZeroMemory(&service->creation_time, sizeof(service->creation_time)); - close_output_handles(&si, ! service->rotate_stdout_online, ! service->rotate_stderr_online); + close_output_handles(&si); if (service->affinity) { /* @@ -1612,6 +1615,8 @@ int stop_service(nssm_service_t *service, unsigned long exitcode, bool graceful, service->wait_handle = 0; } + service->rotate_stdout_online = service->rotate_stderr_online = NSSM_ROTATE_OFFLINE; + if (default_action && ! exitcode && ! graceful) { log_event(EVENTLOG_INFORMATION_TYPE, NSSM_EVENT_GRACEFUL_SUICIDE, service->name, service->exe, exit_action_strings[NSSM_EXIT_UNCLEAN], exit_action_strings[NSSM_EXIT_UNCLEAN], exit_action_strings[NSSM_EXIT_UNCLEAN], exit_action_strings[NSSM_EXIT_REALLY], 0); graceful = true; @@ -1659,6 +1664,8 @@ void CALLBACK end_service(void *arg, unsigned char why) { service->stopping = true; + service->rotate_stdout_online = service->rotate_stderr_online = NSSM_ROTATE_OFFLINE; + /* Check exit code */ unsigned long exitcode = 0; TCHAR code[16];