Exemple #1
0
pid_t Application::StartReloadProcess(void)
{
	Log(LogInformation, "Application", "Got reload command: Starting new instance.");

	// prepare arguments
	Array::Ptr args = new Array();
	args->Add(GetExePath(m_ArgV[0]));

	for (int i=1; i < Application::GetArgC(); i++) {
		if (std::string(Application::GetArgV()[i]) != "--reload-internal")
			args->Add(Application::GetArgV()[i]);
		else
			i++;     // the next parameter after --reload-internal is the pid, remove that too
	}

#ifndef _WIN32
	args->Add("--reload-internal");
	args->Add(Convert::ToString(Utility::GetPid()));
#else /* _WIN32 */
	args->Add("--validate");
#endif /* _WIN32 */

	Process::Ptr process = new Process(Process::PrepareCommand(args));
	process->SetTimeout(300);
	process->Run(&ReloadProcessCallback);

	return process->GetPID();
}
void ConfigPackageUtility::AsyncTryActivateStage(const String& packageName, const String& stageName)
{
	// prepare arguments
	Array::Ptr args = new Array();
	args->Add(Application::GetExePath("icinga2"));
	args->Add("daemon");
	args->Add("--validate");
	args->Add("--define");
	args->Add("ActiveStageOverride=" + packageName + ":" + stageName);

	Process::Ptr process = new Process(Process::PrepareCommand(args));
	process->SetTimeout(300);
	process->Run(boost::bind(&TryActivateStageCallback, _1, packageName, stageName));
}