Please describe the feature you’d like to see added.
It basically works similar to the blocknotify config option which runs a shell script when a block is mined, but the purpose of this new option is different.
It can be called something like “shutdowncomplete” and a shell command is passed to it as an argument, which then runs just before the following message is printed in debug.log:
02023-06-26T14:00:07Z Shutdown: done
It can be ran utilizing a function such as runCommand
.
The reason such an option will be useful is to support automatic updates of Bitcoin Core to newer version. Some 3rd-party program used for detecting new Bitcoin Core releases on bitcoincore.org, downloading/verifying them, installing them to /usr/local or wherever the user-specified path is or alternatively running an installer, needs to be able to stop Bitcoin Core first and know when the process is about to quit so that it can proceed with installing (following which it simply runs the new version of Bitcoin daemon and exits).
Currently this can be done by detecting the bitcoind process, but it’s not portable across multiple operating systems, which all have wildly different Process APIs.
Is your feature related to a problem, if so please describe it.
The problem is: How can Bitcoin Core make it easier to create external programs for automatically updating installations to the newest version?
Describe the solution you’d like
As specified above, a command-line & config option for running a shell script right before shutdown is the solution for facilitating automatic updates of bitcoin core (similar to stuff like Livepatch and k-splice for the linux kernel).
Describe any alternatives you’ve considered
As noted, the bitcoind process can be detected in the running process lists, but this can cause a deadlock inside applications if Bitcoin Core takes a long time to shut down (eg. a network thread takes too long to exit).
Please leave any additional context
None.