X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;ds=sidebyside;f=nssm.cpp;h=6456c9735c4066a8f7fed4222def6077714a8b36;hb=b0a6672810ee06052dc3dcf268274d06f0e82a50;hp=498a213abea9455ec7b14d58e4e5b8bdb8db7f4e;hpb=2cd1c7c29ef4d2d3df3c5afd3ca6c788aede2bef;p=nssm.git diff --git a/nssm.cpp b/nssm.cpp index 498a213..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,8 +83,13 @@ 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));