Skip to content

contrib/init: (OpenRC) use -startupnotify to wait for startup completion [alternative]

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 090530cc (#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's start_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.

Merge request reports

Loading