mirror of https://github.com/Icinga/icinga2.git
Implement ApiListener status file removal on shutdown
This commit is contained in:
parent
20269a89d0
commit
ecb73e08ed
|
@ -264,8 +264,12 @@ void ApiListener::Stop(bool runtimeDeleted)
|
|||
Log(LogInformation, "ApiListener")
|
||||
<< "'" << GetName() << "' stopped.";
|
||||
|
||||
boost::mutex::scoped_lock lock(m_LogLock);
|
||||
CloseLogFile();
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_LogLock);
|
||||
CloseLogFile();
|
||||
}
|
||||
|
||||
RemoveStatusFile();
|
||||
}
|
||||
|
||||
ApiListener::Ptr ApiListener::GetInstance()
|
||||
|
@ -1482,3 +1486,17 @@ void ApiListener::UpdateStatusFile(TcpSocket::Ptr socket)
|
|||
{"port", details.second}
|
||||
}));
|
||||
}
|
||||
|
||||
void ApiListener::RemoveStatusFile()
|
||||
{
|
||||
String path = Application::GetConst("CacheDir") + "/api-state.json";
|
||||
|
||||
if (Utility::PathExists(path)) {
|
||||
if (unlink(path.CStr()) < 0 && errno != ENOENT) {
|
||||
BOOST_THROW_EXCEPTION(posix_error()
|
||||
<< boost::errinfo_api_function("unlink")
|
||||
<< boost::errinfo_errno(errno)
|
||||
<< boost::errinfo_file_name(path));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,8 +114,6 @@ protected:
|
|||
void Start(bool runtimeCreated) override;
|
||||
void Stop(bool runtimeDeleted) override;
|
||||
|
||||
void UpdateStatusFile(TcpSocket::Ptr socket);
|
||||
|
||||
void ValidateTlsProtocolmin(const Lazy<String>& lvalue, const ValidationUtils& utils) override;
|
||||
|
||||
private:
|
||||
|
@ -165,6 +163,9 @@ private:
|
|||
|
||||
static void CopyCertificateFile(const String& oldCertPath, const String& newCertPath);
|
||||
|
||||
void UpdateStatusFile(TcpSocket::Ptr socket);
|
||||
void RemoveStatusFile();
|
||||
|
||||
/* filesync */
|
||||
static ConfigDirInformation LoadConfigDir(const String& dir);
|
||||
static Dictionary::Ptr MergeConfigUpdate(const ConfigDirInformation& config);
|
||||
|
|
Loading…
Reference in New Issue