mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-26 23:24:09 +02:00
Implement ApiListener status file removal on shutdown
This commit is contained in:
parent
20269a89d0
commit
ecb73e08ed
@ -264,10 +264,14 @@ void ApiListener::Stop(bool runtimeDeleted)
|
|||||||
Log(LogInformation, "ApiListener")
|
Log(LogInformation, "ApiListener")
|
||||||
<< "'" << GetName() << "' stopped.";
|
<< "'" << GetName() << "' stopped.";
|
||||||
|
|
||||||
|
{
|
||||||
boost::mutex::scoped_lock lock(m_LogLock);
|
boost::mutex::scoped_lock lock(m_LogLock);
|
||||||
CloseLogFile();
|
CloseLogFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RemoveStatusFile();
|
||||||
|
}
|
||||||
|
|
||||||
ApiListener::Ptr ApiListener::GetInstance()
|
ApiListener::Ptr ApiListener::GetInstance()
|
||||||
{
|
{
|
||||||
return m_Instance;
|
return m_Instance;
|
||||||
@ -1482,3 +1486,17 @@ void ApiListener::UpdateStatusFile(TcpSocket::Ptr socket)
|
|||||||
{"port", details.second}
|
{"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 Start(bool runtimeCreated) override;
|
||||||
void Stop(bool runtimeDeleted) override;
|
void Stop(bool runtimeDeleted) override;
|
||||||
|
|
||||||
void UpdateStatusFile(TcpSocket::Ptr socket);
|
|
||||||
|
|
||||||
void ValidateTlsProtocolmin(const Lazy<String>& lvalue, const ValidationUtils& utils) override;
|
void ValidateTlsProtocolmin(const Lazy<String>& lvalue, const ValidationUtils& utils) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -165,6 +163,9 @@ private:
|
|||||||
|
|
||||||
static void CopyCertificateFile(const String& oldCertPath, const String& newCertPath);
|
static void CopyCertificateFile(const String& oldCertPath, const String& newCertPath);
|
||||||
|
|
||||||
|
void UpdateStatusFile(TcpSocket::Ptr socket);
|
||||||
|
void RemoveStatusFile();
|
||||||
|
|
||||||
/* filesync */
|
/* filesync */
|
||||||
static ConfigDirInformation LoadConfigDir(const String& dir);
|
static ConfigDirInformation LoadConfigDir(const String& dir);
|
||||||
static Dictionary::Ptr MergeConfigUpdate(const ConfigDirInformation& config);
|
static Dictionary::Ptr MergeConfigUpdate(const ConfigDirInformation& config);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user