aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Carman <benthecarman@live.com>2020-09-28 10:38:36 -0500
committerBen Carman <benthecarman@live.com>2020-09-28 10:38:36 -0500
commit090530cc24054d6b4658752bb88f75a3b73eab5d (patch)
treec89f951712e3e27ab495b9f285ce0ccb63f6ea4f
parent30568d3f1e238f6900265914c2d449adcc355c66 (diff)
feature: Added ability for users to add a startup command
-rw-r--r--doc/release-notes-15367.md6
-rw-r--r--src/init.cpp18
2 files changed, 24 insertions, 0 deletions
diff --git a/doc/release-notes-15367.md b/doc/release-notes-15367.md
new file mode 100644
index 0000000000..598e49dcae
--- /dev/null
+++ b/doc/release-notes-15367.md
@@ -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) \ No newline at end of file
diff --git a/src/init.cpp b/src/init.cpp
index ecd57960ad..08075f87c8 100644
--- a/src/init.cpp
+++ b/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-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);
+#if HAVE_SYSTEM
+ argsman.AddArg("-startupnotify=<cmd>", "Execute command on startup.", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
+#endif
#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);
#else
@@ -670,6 +673,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)
{
const CChainParams& chainparams = Params();
@@ -1969,5 +1983,9 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA
banman->DumpBanlist();
}, DUMP_BANS_INTERVAL);
+#if HAVE_SYSTEM
+ StartupNotify(args);
+#endif
+
return true;
}