lastLoop = now;
}
-
+
if (m_RequestRestart) {
m_RequestRestart = false; // we are now handling the request, once is enough
goto mainloop;
}
-
+
Log(LogInformation, "Application", "Shutting down Icinga...");
DynamicObject::StopObjects();
Application::GetInstance()->OnShutdown();
Process::Ptr process = make_shared<Process>(Process::PrepareCommand(args));
process->SetTimeout(300);
process->Run(&ReloadProcessCallback);
-
+
return process->GetPID();
}
ScriptVariable::GetByName("PrefixDir")->SetConstant(true);
ScriptVariable::GetByName("SysconfDir")->SetConstant(true);
ScriptVariable::GetByName("LocalStateDir")->SetConstant(true);
+ ScriptVariable::GetByName("RunDir")->SetConstant(true);
ScriptVariable::GetByName("PkgDataDir")->SetConstant(true);
ScriptVariable::GetByName("StatePath")->SetConstant(false);
ScriptVariable::GetByName("PidPath")->SetConstant(false);
}
Endpoint::Ptr my_endpoint = Endpoint::GetLocalEndpoint();
+
+ if (!my_endpoint) {
+ Log(LogWarning, "ApiEvents", "No local endpoint defined. Bailing out.");
+ return;
+ }
+
Zone::Ptr my_zone = my_endpoint->GetZone();
Dictionary::Ptr params = make_shared<Dictionary>();
String ApiEvents::GetVirtualHostName(const Host::Ptr& host)
{
String host_name = host->GetName();
- if (host_name == "localhost")
- host_name = Endpoint::GetLocalEndpoint()->GetName();
+ if (host_name == "localhost") {
+ Endpoint::Ptr local = Endpoint::GetLocalEndpoint();
+
+ if (!local)
+ return Empty;
+
+ host_name = local->GetName();
+ }
+
return host_name;
}
Host::Ptr ApiEvents::FindHostByVirtualName(const String& hostName)
{
- if (hostName == Endpoint::GetLocalEndpoint()->GetName())
+ Endpoint::Ptr local = Endpoint::GetLocalEndpoint();
+
+ if (!local)
+ return Host::Ptr();
+
+ if (hostName == local->GetName())
return Host::GetByName("localhost");
else
return Host::GetByName(hostName);