contrib/init: (OpenRC) use -startupnotify to wait for startup completion [alternative] #22354
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an alternative to #22285 to address @luke-jr's concern.
When other initscripts depend on bitcoind, it's because their daemons want to be able to invoke
bitcoin-cli
or to communicate with bitcoind via RPC. That can't happen until some time after bitcoind has forked into the background. The-startupnotify
option was added in 090530c (#15367) to support exactly this use case, so let's use it.A straightforward and reliable way to wait for bitcoind to invoke its
-startupnotify
command is to make bitcoind hold a lock on a dummy file and release that lock via the-startupnotify
command. The initscript'sstart_post()
function initially marks the service as inactive and forks a subshell process into the background to wait for bitcoind to release the lock file, which will happen when bitcoind either executes the-startupnotify
command or dies. After acquiring and releasing the lock, the subshell checks whether the pid file still exists and marks the service as started or stopped appropriately.