diff --git a/doc/release-notes-15367.md b/doc/release-notes-15367.md new file mode 100644 index 0000000000000..fed8967bc0f77 --- /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 Dash Core has finished with its startup + sequence. (#5728) \ No newline at end of file diff --git a/src/init.cpp b/src/init.cpp index 041578528f73a..f38f8cfd24dde 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -539,6 +539,9 @@ void SetupServerArgs(NodeContext& node) "(default: 0 = disable pruning blocks, 1 = allow manual pruning via RPC, >%u = automatically prune block files to stay under the specified target size in MiB)", MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); argsman.AddArg("-settings=", 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("-syncmempool", strprintf("Sync mempool from other nodes on start (default: %u)", DEFAULT_SYNC_MEMPOOL), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); +#if HAVE_SYSTEM + argsman.AddArg("-startupnotify=", "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 @@ -859,6 +862,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 PeriodicStats(ArgsManager& args, const CTxMemPool& mempool) { assert(args.GetBoolArg("-statsenabled", DEFAULT_STATSD_ENABLE)); @@ -2537,5 +2551,9 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc banman->DumpBanlist(); }, DUMP_BANS_INTERVAL); +#if HAVE_SYSTEM + StartupNotify(args); +#endif + return true; }