mirror of https://github.com/Icinga/icinga2.git
Merge pull request #6367 from Icinga/windows-reload
Revert "Fix Windows reload"
This commit is contained in:
commit
4eb5b0967c
|
@ -416,8 +416,7 @@ pid_t Application::StartReloadProcess()
|
||||||
args.push_back("--reload-internal");
|
args.push_back("--reload-internal");
|
||||||
args.push_back(Convert::ToString(Utility::GetPid()));
|
args.push_back(Convert::ToString(Utility::GetPid()));
|
||||||
#else /* _WIN32 */
|
#else /* _WIN32 */
|
||||||
args.push_back("--restart-service");
|
args.push_back("--validate");
|
||||||
args.push_back("icinga2");
|
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
Process::Ptr process = new Process(Process::PrepareCommand(new Array(std::move(args))));
|
Process::Ptr process = new Process(Process::PrepareCommand(new Array(std::move(args))));
|
||||||
|
|
|
@ -162,9 +162,6 @@ void DaemonCommand::InitParameters(boost::program_options::options_description&
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
hiddenDesc.add_options()
|
hiddenDesc.add_options()
|
||||||
("reload-internal", po::value<int>(), "used internally to implement config reload: do not call manually, send SIGHUP instead");
|
("reload-internal", po::value<int>(), "used internally to implement config reload: do not call manually, send SIGHUP instead");
|
||||||
#else
|
|
||||||
hiddenDesc.add_options()
|
|
||||||
("restart-service", po::value<std::string>(), "tries to restart the Icinga 2 service");
|
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,42 +211,6 @@ int DaemonCommand::Run(const po::variables_map& vm, const std::vector<std::strin
|
||||||
if (!DaemonUtility::LoadConfigFiles(configs, newItems, Application::GetObjectsPath(), Application::GetVarsPath()))
|
if (!DaemonUtility::LoadConfigFiles(configs, newItems, Application::GetObjectsPath(), Application::GetVarsPath()))
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
if (vm.count("restart-service")) {
|
|
||||||
SC_HANDLE handleManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
|
|
||||||
if (!handleManager) {
|
|
||||||
Log(LogCritical, "cli") << "Failed to open service manager. Error code: " << GetLastError();
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string service = vm["restart-service"].as<std::string>();
|
|
||||||
|
|
||||||
SC_HANDLE handleService = OpenService(handleManager, service.c_str(), SERVICE_START | SERVICE_STOP);
|
|
||||||
if (!handleService) {
|
|
||||||
Log(LogCritical, "cli") << "Failed to open service handle of '" << service << "'. Error code: " << GetLastError();
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
SERVICE_STATUS serviceStatus;
|
|
||||||
if (!ControlService(handleService, SERVICE_CONTROL_STOP, &serviceStatus)) {
|
|
||||||
DWORD error = GetLastError();
|
|
||||||
if (error = ERROR_SERVICE_NOT_ACTIVE)
|
|
||||||
Log(LogInformation, "cli") << "Service '" << service << "' is not running.";
|
|
||||||
else {
|
|
||||||
Log(LogCritical, "cli") << "Failed to stop service. Error code: " << GetLastError();
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!StartService(handleService, 0, NULL)) {
|
|
||||||
Log(LogCritical, "cli") << "Failed to start up service '" << service << "'. Error code: " << GetLastError();
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
|
||||||
#endif /* _WIN32 */
|
|
||||||
|
|
||||||
if (vm.count("validate")) {
|
if (vm.count("validate")) {
|
||||||
Log(LogInformation, "cli", "Finished validating the configuration file(s).");
|
Log(LogInformation, "cli", "Finished validating the configuration file(s).");
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
|
Loading…
Reference in New Issue