--------------------|-------------------
Vars |**Read-write.** Contains a dictionary with global custom attributes. Not set by default.
NodeName |**Read-write.** Contains the cluster node name. Set to the local hostname by default.
+ReloadTimeout |**Read-write.** Defines the reload timeout for child processes. Defaults to `300s`.
Environment |**Read-write.** The name of the Icinga environment. Included in the SNI host name for outbound connections. Not set by default.
RunAsUser |**Read-write.** Defines the user the Icinga 2 daemon is running as. Set in the Icinga 2 sysconfig.
RunAsGroup |**Read-write.** Defines the group the Icinga 2 daemon is running as. Set in the Icinga 2 sysconfig.
ASSERT(m_Instance == nullptr);
m_Instance = this;
+
+ String reloadTimeout;
+
+ if (ScriptGlobal::Exists("ReloadTimeout"))
+ reloadTimeout = ScriptGlobal::Get("ReloadTimeout");
+
+ if (!reloadTimeout.IsEmpty())
+ Configuration::ReloadTimeout = Convert::ToDouble(reloadTimeout);
}
/**
pid_t Application::StartReloadProcess()
{
- Log(LogInformation, "Application", "Got reload command: Starting new instance.");
-
// prepare arguments
ArrayData args;
args.push_back(GetExePath(m_ArgV[0]));
#endif /* _WIN32 */
Process::Ptr process = new Process(Process::PrepareCommand(new Array(std::move(args))));
- process->SetTimeout(300);
+ process->SetTimeout(Configuration::ReloadTimeout);
process->Run(&ReloadProcessCallback);
+ Log(LogInformation, "Application")
+ << "Got reload command: Started new instance with PID '"
+ << (unsigned long)(process->GetPID()) << "' (timeout is "
+ << Configuration::ReloadTimeout << "s).";
+
return process->GetPID();
}
String Configuration::PkgDataDir;
String Configuration::PrefixDir;
String Configuration::ProgramData;
+double Configuration::ReloadTimeout{300};
int Configuration::RLimitFiles;
int Configuration::RLimitProcesses;
int Configuration::RLimitStack;
HandleUserWrite("ProgramData", &Configuration::ProgramData, val, m_ReadOnly);
}
+double Configuration::GetReloadTimeout() const
+{
+ return Configuration::ReloadTimeout;
+}
+
+void Configuration::SetReloadTimeout(double val, bool suppress_events, const Value& cookie)
+{
+ HandleUserWrite("ReloadTimeout", &Configuration::ReloadTimeout, val, m_ReadOnly);
+}
+
int Configuration::GetRLimitFiles() const
{
return Configuration::RLimitFiles;
String GetProgramData() const override;
void SetProgramData(const String& value, bool suppress_events = false, const Value& cookie = Empty) override;
+ double GetReloadTimeout() const override;
+ void SetReloadTimeout(double value, bool suppress_events = false, const Value& cookie = Empty) override;
+
int GetRLimitFiles() const override;
void SetRLimitFiles(int value, bool suppress_events = false, const Value& cookie = Empty) override;
static String PkgDataDir;
static String PrefixDir;
static String ProgramData;
+ static double ReloadTimeout;
static int RLimitFiles;
static int RLimitProcesses;
static int RLimitStack;
set;
};
+ [config, no_storage, virtual] double ReloadTimeout {
+ get;
+ set;
+ };
+
[config, no_storage, virtual] int RLimitFiles {
get;
set;
void CheckerComponent::Stop(bool runtimeRemoved)
{
- Log(LogInformation, "CheckerComponent")
- << "'" << GetName() << "' stopped.";
-
{
boost::mutex::scoped_lock lock(m_Mutex);
m_Stopped = true;
m_CV.notify_all();
}
+ double wait = 0.0;
+
+ while (GetPendingCheckables() > 0) {
+ Log(LogDebug, "CheckerComponent")
+ << "Waiting for running checks (" << GetPendingCheckables()
+ << ") to finish. Waited for " << wait << " seconds now.";
+
+ Utility::Sleep(0.1);
+ wait += 0.1;
+
+ /* Pick a timeout slightly shorther than the process reload timeout. */
+ double waitMax = Configuration::ReloadTimeout - 30;
+ if (waitMax <= 0)
+ waitMax = 1;
+
+ if (wait > waitMax) {
+ Log(LogWarning, "CheckerComponent")
+ << "Checks running too long for " << wait
+ << " seconds, hard shutdown before reload timeout: " << Configuration::ReloadTimeout << ".";
+ break;
+ }
+ }
+
m_ResultTimer->Stop();
m_Thread.join();
+ Log(LogInformation, "CheckerComponent")
+ << "'" << GetName() << "' stopped.";
+
ObjectImpl<CheckerComponent>::Stop(runtimeRemoved);
}
args->Add("ActiveStageOverride=" + packageName + ":" + stageName);
Process::Ptr process = new Process(Process::PrepareCommand(args));
- process->SetTimeout(300);
+ process->SetTimeout(Configuration::ReloadTimeout);
process->Run(std::bind(&TryActivateStageCallback, _1, packageName, stageName, reload));
}