X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=nssm.cpp;h=6456c9735c4066a8f7fed4222def6077714a8b36;hb=b0a6672810ee06052dc3dcf268274d06f0e82a50;hp=8dd264ad713d9aa001490fd2c8a2a3fb7a941f33;hpb=153133aedadde24a5836707caa3ae3632e422ef3;p=nssm.git diff --git a/nssm.cpp b/nssm.cpp index 8dd264a..6456c97 100644 --- a/nssm.cpp +++ b/nssm.cpp @@ -55,26 +55,6 @@ void check_admin() { FreeSid(AdministratorsGroup); } -/* See if we were launched from a console window. */ -static void check_console() { - /* If we're running in a service context there will be no console window. */ - HWND console = GetConsoleWindow(); - if (! console) return; - - unsigned long pid; - if (! GetWindowThreadProcessId(console, &pid)) return; - - /* - If the process associated with the console window handle is the same as - this process, we were not launched from an existing console. The user - probably double-clicked our executable. - */ - if (GetCurrentProcessId() != pid) return; - - /* We close our new console so that subsequent messages appear in a popup. */ - FreeConsole(); -} - int num_cpus() { DWORD_PTR i, affinity, system_affinity; if (! GetProcessAffinityMask(GetCurrentProcess(), &affinity, &system_affinity)) return 64; @@ -103,11 +83,17 @@ int _tmain(int argc, TCHAR **argv) { Valid commands are: start, stop, pause, continue, install, edit, get, set, reset, unset, remove */ - if (str_equiv(argv[1], _T("start"))) exit(control_service(0, argc - 2, argv + 2)); + 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)); + if (str_equiv(argv[1], _T("rotate"))) exit(control_service(NSSM_SERVICE_CONTROL_ROTATE, argc - 2, argv + 2)); if (str_equiv(argv[1], _T("install"))) { if (! is_admin) { print_message(stderr, NSSM_MESSAGE_NOT_ADMINISTRATOR_CANNOT_INSTALL);