mirror of https://github.com/Icinga/icinga2.git
GelfWriter: Ensure to join queue and execute queries on Pause/Shutdown/Reload
This commit is contained in:
parent
24c3572b03
commit
68e7027c93
|
@ -107,12 +107,26 @@ void GelfWriter::Resume()
|
|||
Checkable::OnStateChange.connect(std::bind(&GelfWriter::StateChangeHandler, this, _1, _2, _3));
|
||||
}
|
||||
|
||||
/* Pause is equivalent to Stop, but with HA capabilities to resume at runtime. */
|
||||
void GelfWriter::Pause()
|
||||
{
|
||||
Log(LogInformation, "GelfWriter")
|
||||
<< "'" << GetName() << "' paused.";
|
||||
m_ReconnectTimer.reset();
|
||||
|
||||
try {
|
||||
ReconnectInternal();
|
||||
} catch (const std::exception&) {
|
||||
Log(LogInformation, "GelfWriter")
|
||||
<< "'" << GetName() << "' paused. Unable to connect, not flushing buffers. Data may be lost on reload.";
|
||||
|
||||
ObjectImpl<GelfWriter>::Pause();
|
||||
return;
|
||||
}
|
||||
|
||||
m_WorkQueue.Join();
|
||||
DisconnectInternal();
|
||||
|
||||
Log(LogInformation, "GraphiteWriter")
|
||||
<< "'" << GetName() << "' paused.";
|
||||
|
||||
ObjectImpl<GelfWriter>::Pause();
|
||||
}
|
||||
|
@ -145,6 +159,11 @@ void GelfWriter::Reconnect()
|
|||
return;
|
||||
}
|
||||
|
||||
ReconnectInternal();
|
||||
}
|
||||
|
||||
void GelfWriter::ReconnectInternal()
|
||||
{
|
||||
double startTime = Utility::GetTime();
|
||||
|
||||
CONTEXT("Reconnecting to Graylog Gelf '" + GetName() + "'");
|
||||
|
@ -184,6 +203,11 @@ void GelfWriter::Disconnect()
|
|||
{
|
||||
AssertOnWorkQueue();
|
||||
|
||||
DisconnectInternal();
|
||||
}
|
||||
|
||||
void GelfWriter::DisconnectInternal()
|
||||
{
|
||||
if (!GetConnected())
|
||||
return;
|
||||
|
||||
|
|
|
@ -72,7 +72,9 @@ private:
|
|||
void ReconnectTimerHandler();
|
||||
|
||||
void Disconnect();
|
||||
void DisconnectInternal();
|
||||
void Reconnect();
|
||||
void ReconnectInternal();
|
||||
|
||||
void AssertOnWorkQueue();
|
||||
|
||||
|
|
Loading…
Reference in New Issue