Move all PID file stuff to init.cpp
It is only used from init.cpp. Move-only refactoring.
This commit is contained in:
3 files changed
+24
-26
No files matched your search
+24
-14
@@ -94,6 +94,30 @@ std::unique_ptr<BanMan> g_banman;
|
|||||||
|
|
||||||
static const char* FEE_ESTIMATES_FILENAME="fee_estimates.dat";
|
static const char* FEE_ESTIMATES_FILENAME="fee_estimates.dat";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The PID file facilities.
|
||||||
|
*/
|
||||||
|
#ifndef WIN32
|
||||||
|
static const char* BITCOIN_PID_FILENAME = "bitcoind.pid";
|
||||||
|
|
||||||
|
static fs::path GetPidFile()
|
||||||
|
{
|
||||||
|
return AbsPathForConfigVal(fs::path(gArgs.GetArg("-pid", BITCOIN_PID_FILENAME)));
|
||||||
|
}
|
||||||
|
|
||||||
|
NODISCARD static bool CreatePidFile()
|
||||||
|
{
|
||||||
|
FILE* file = fsbridge::fopen(GetPidFile(), "w");
|
||||||
|
if (file) {
|
||||||
|
fprintf(file, "%d\n", getpid());
|
||||||
|
fclose(file);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return InitError(strprintf(_("Unable to create the PID file '%s': %s"), GetPidFile().string(), std::strerror(errno)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Shutdown
|
// Shutdown
|
||||||
@@ -1194,20 +1218,6 @@ bool AppInitLockDataDirectory()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef WIN32
|
|
||||||
NODISCARD static bool CreatePidFile()
|
|
||||||
{
|
|
||||||
FILE* file = fsbridge::fopen(GetPidFile(), "w");
|
|
||||||
if (file) {
|
|
||||||
fprintf(file, "%d\n", getpid());
|
|
||||||
fclose(file);
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return InitError(strprintf(_("Unable to create the PID file '%s': %s"), GetPidFile().string(), std::strerror(errno)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool AppInitMain(InitInterfaces& interfaces)
|
bool AppInitMain(InitInterfaces& interfaces)
|
||||||
{
|
{
|
||||||
const CChainParams& chainparams = Params();
|
const CChainParams& chainparams = Params();
|
||||||
|
|||||||
@@ -79,7 +79,6 @@
|
|||||||
const int64_t nStartupTime = GetTime();
|
const int64_t nStartupTime = GetTime();
|
||||||
|
|
||||||
const char * const BITCOIN_CONF_FILENAME = "bitcoin.conf";
|
const char * const BITCOIN_CONF_FILENAME = "bitcoin.conf";
|
||||||
const char * const BITCOIN_PID_FILENAME = "bitcoind.pid";
|
|
||||||
|
|
||||||
ArgsManager gArgs;
|
ArgsManager gArgs;
|
||||||
|
|
||||||
@@ -958,13 +957,6 @@ std::string ArgsManager::GetChainName() const
|
|||||||
return CBaseChainParams::MAIN;
|
return CBaseChainParams::MAIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef WIN32
|
|
||||||
fs::path GetPidFile()
|
|
||||||
{
|
|
||||||
return AbsPathForConfigVal(fs::path(gArgs.GetArg("-pid", BITCOIN_PID_FILENAME)));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool RenameOver(fs::path src, fs::path dest)
|
bool RenameOver(fs::path src, fs::path dest)
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
|||||||
@@ -39,7 +39,6 @@
|
|||||||
int64_t GetStartupTime();
|
int64_t GetStartupTime();
|
||||||
|
|
||||||
extern const char * const BITCOIN_CONF_FILENAME;
|
extern const char * const BITCOIN_CONF_FILENAME;
|
||||||
extern const char * const BITCOIN_PID_FILENAME;
|
|
||||||
|
|
||||||
/** Translate a message to the native language of the user. */
|
/** Translate a message to the native language of the user. */
|
||||||
const extern std::function<std::string(const char*)> G_TRANSLATION_FUN;
|
const extern std::function<std::string(const char*)> G_TRANSLATION_FUN;
|
||||||
@@ -84,9 +83,6 @@ const fs::path &GetBlocksDir();
|
|||||||
const fs::path &GetDataDir(bool fNetSpecific = true);
|
const fs::path &GetDataDir(bool fNetSpecific = true);
|
||||||
void ClearDatadirCache();
|
void ClearDatadirCache();
|
||||||
fs::path GetConfigFile(const std::string& confPath);
|
fs::path GetConfigFile(const std::string& confPath);
|
||||||
#ifndef WIN32
|
|
||||||
fs::path GetPidFile();
|
|
||||||
#endif
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
fs::path GetSpecialFolderPath(int nFolder, bool fCreate = true);
|
fs::path GetSpecialFolderPath(int nFolder, bool fCreate = true);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in new issue
Block a user