mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
Merge #15367: feature: Added ability for users to add a startup command
090530cc24feature: Added ability for users to add a startup command (Ben Carman) Pull request description: Thoughts for adding the feature is for users to be able to add things like electrum-personal-server or lnd to run whenever Bitcoin Core is running. Open to feedback about the feature. ACKs for top commit: MarcoFalke: re-ACK090530cc24dongcarl: tACK090530cTree-SHA512: ba514d2fc8b4fb12b781c1a9c89845a25fce0b80ba7c907761cde4abb81edd03fa643682edc895986dc20b273ac3b95769508806db7fbd99ec28623f85c41e67
This commit is contained in:
6
doc/release-notes-15367.md
Normal file
6
doc/release-notes-15367.md
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
Configuration option changes
|
||||||
|
----------------------------
|
||||||
|
|
||||||
|
- The `startupnotify` option is used to specify a command to
|
||||||
|
execute when Bitcoin Core has finished with its startup
|
||||||
|
sequence. (#15367)
|
||||||
18
src/init.cpp
18
src/init.cpp
@@ -422,6 +422,9 @@ void SetupServerArgs(NodeContext& node)
|
|||||||
argsman.AddArg("-reindex", "Rebuild chain state and block index from the blk*.dat files on disk", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
argsman.AddArg("-reindex", "Rebuild chain state and block index from the blk*.dat files on disk", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
||||||
argsman.AddArg("-reindex-chainstate", "Rebuild chain state from the currently indexed blocks. When in pruning mode or if blocks on disk might be corrupted, use full -reindex instead.", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
argsman.AddArg("-reindex-chainstate", "Rebuild chain state from the currently indexed blocks. When in pruning mode or if blocks on disk might be corrupted, use full -reindex instead.", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
||||||
argsman.AddArg("-settings=<file>", strprintf("Specify path to dynamic settings data file. Can be disabled with -nosettings. File is written at runtime and not meant to be edited by users (use %s instead for custom settings). Relative paths will be prefixed by datadir location. (default: %s)", BITCOIN_CONF_FILENAME, BITCOIN_SETTINGS_FILENAME), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
argsman.AddArg("-settings=<file>", strprintf("Specify path to dynamic settings data file. Can be disabled with -nosettings. File is written at runtime and not meant to be edited by users (use %s instead for custom settings). Relative paths will be prefixed by datadir location. (default: %s)", BITCOIN_CONF_FILENAME, BITCOIN_SETTINGS_FILENAME), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
||||||
|
#if HAVE_SYSTEM
|
||||||
|
argsman.AddArg("-startupnotify=<cmd>", "Execute command on startup.", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
||||||
|
#endif
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
argsman.AddArg("-sysperms", "Create new files with system default permissions, instead of umask 077 (only effective with disabled wallet functionality)", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
argsman.AddArg("-sysperms", "Create new files with system default permissions, instead of umask 077 (only effective with disabled wallet functionality)", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
|
||||||
#else
|
#else
|
||||||
@@ -674,6 +677,17 @@ static void CleanupBlockRevFiles()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if HAVE_SYSTEM
|
||||||
|
static void StartupNotify(const ArgsManager& args)
|
||||||
|
{
|
||||||
|
std::string cmd = args.GetArg("-startupnotify", "");
|
||||||
|
if (!cmd.empty()) {
|
||||||
|
std::thread t(runCommand, cmd);
|
||||||
|
t.detach(); // thread runs free
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void ThreadImport(ChainstateManager& chainman, std::vector<fs::path> vImportFiles, const ArgsManager& args)
|
static void ThreadImport(ChainstateManager& chainman, std::vector<fs::path> vImportFiles, const ArgsManager& args)
|
||||||
{
|
{
|
||||||
const CChainParams& chainparams = Params();
|
const CChainParams& chainparams = Params();
|
||||||
@@ -1973,5 +1987,9 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA
|
|||||||
banman->DumpBanlist();
|
banman->DumpBanlist();
|
||||||
}, DUMP_BANS_INTERVAL);
|
}, DUMP_BANS_INTERVAL);
|
||||||
|
|
||||||
|
#if HAVE_SYSTEM
|
||||||
|
StartupNotify(args);
|
||||||
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user