aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Sadie Powell2022-04-23 09:46:28 +0100
committerGravatar Sadie Powell2022-04-23 09:57:52 +0100
commitd682f3f2c962d4f6f986ade58cf3c1dc4adfbc67 (patch)
tree2a29ba1486a77571f564254a5be1c4dac45e8dbf /src
parentMerge branch 'insp3' into master. (diff)
Only write to the pid file on boot.
Being able to change this after first boot is error prone and does not work well on system-wide installs where the server needs root to write the file. Closes #566.
Diffstat (limited to 'src')
-rw-r--r--src/configreader.cpp4
-rw-r--r--src/inspircd.cpp12
2 files changed, 5 insertions, 11 deletions
diff --git a/src/configreader.cpp b/src/configreader.cpp
index 81e70fae7..6cdd869ba 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -448,10 +448,6 @@ void ServerConfig::Apply(ServerConfig* old, const std::string &useruid)
// Check errors before dealing with failed binds, since continuing on failed bind is wanted in some circumstances.
valid = errstr.str().empty();
- // write once here, to try it out and make sure its ok
- if (valid)
- ServerInstance->WritePID(!old);
-
auto binds = ConfTags("bind");
if (binds.empty())
errstr << "Possible configuration error: you have not defined any <bind> blocks." << std::endl
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 9ea707d97..943de329b 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -418,7 +418,7 @@ void InspIRCd::Cleanup()
Logs.CloseLogs();
}
-void InspIRCd::WritePID(bool exitonfail)
+void InspIRCd::WritePID()
{
#ifndef _WIN32
if (!ServerInstance->Config->cmdline.writepid)
@@ -436,11 +436,9 @@ void InspIRCd::WritePID(bool exitonfail)
}
else
{
- if (exitonfail)
- std::cout << "Failed to write PID-file '" << pidfile << "', exiting." << std::endl;
- this->Logs.Log("STARTUP", LOG_DEFAULT, "Failed to write PID-file '%s'%s", pidfile.c_str(), (exitonfail ? ", exiting." : ""));
- if (exitonfail)
- Exit(EXIT_STATUS_PID);
+ std::cout << "Failed to write PID-file '" << pidfile << "', exiting." << std::endl;
+ this->Logs.Log("STARTUP", LOG_DEFAULT, "Failed to write PID-file '%s', exiting.", pidfile.c_str());
+ Exit(EXIT_STATUS_PID);
}
#endif
}
@@ -586,7 +584,7 @@ InspIRCd::InspIRCd(int argc, char** argv)
QueryPerformanceFrequency(&stats.QPFrequency);
#endif
- WritePID(true);
+ WritePID();
DropRoot();
Logs.Log("STARTUP", LOG_DEFAULT, "Startup complete as '%s'[%s], %lu max open sockets", Config->ServerName.c_str(),Config->GetSID().c_str(), SocketEngine::GetMaxFds());