mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
util: Add -shutdownnotify option.
This commit is contained in:
17
src/init.cpp
17
src/init.cpp
@@ -189,8 +189,24 @@ static fs::path GetPidFile(const ArgsManager& args)
|
||||
// shutdown thing.
|
||||
//
|
||||
|
||||
#if HAVE_SYSTEM
|
||||
static void ShutdownNotify(const ArgsManager& args)
|
||||
{
|
||||
std::vector<std::thread> threads;
|
||||
for (const auto& cmd : args.GetArgs("-shutdownnotify")) {
|
||||
threads.emplace_back(runCommand, cmd);
|
||||
}
|
||||
for (auto& t : threads) {
|
||||
t.join();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void Interrupt(NodeContext& node)
|
||||
{
|
||||
#if HAVE_SYSTEM
|
||||
ShutdownNotify(*node.args);
|
||||
#endif
|
||||
InterruptHTTPServer();
|
||||
InterruptHTTPRPC();
|
||||
InterruptRPC();
|
||||
@@ -439,6 +455,7 @@ void SetupServerArgs(ArgsManager& argsman)
|
||||
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);
|
||||
argsman.AddArg("-shutdownnotify=<cmd>", "Execute command immediately before beginning shutdown. The need for shutdown may be urgent, so be careful not to delay it long (if the command doesn't require interaction with the server, consider having it fork into the background).", 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);
|
||||
|
||||
Reference in New Issue
Block a user