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

pull whitslack wants to merge 1 commits into bitcoin:master from whitslack:openrc-startupnotify-bkg changing 1 files +31 −4
  1. whitslack commented at 7:54 pm on June 27, 2021: contributor

    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 090530cc24 (#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.

  2. contrib/init: (OpenRC) use -startupnotify to wait for startup completion
    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 090530cc24
    (#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.
    698e793a80
  3. in contrib/init/bitcoind.openrc:33 in 698e793a80
    32+		/usr/bin/bitcoind
    33+		$(/usr/bin/printf '%s=%q ' \
    34+			-pid "${BITCOIND_PIDFILE}" \
    35+			-conf "${BITCOIND_CONFIGFILE}" \
    36+			-datadir "${BITCOIND_DATADIR}" \
    37+			-startupnotify "flock -u 3") \
    


    luke-jr commented at 8:22 pm on June 27, 2021:

    Hmm, one side effect of using startupnotify here is that the user can no longer use it himself…

    Maybe we need to fix this to allow multiple -*notify commands?


    whitslack commented at 2:39 am on June 28, 2021:
    I definitely think the -*notify options should stack, but I don’t think that’s a big concern with respect to this PR. If a user wants something to happen when bitcoind is ready to handle RPC requests, they would just create an initscript that depends on bitcoind and let OpenRC handle the sequencing.
  4. DrahtBot added the label Scripts and tools on Jun 27, 2021
  5. DrahtBot commented at 6:03 am on June 28, 2021: member

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #22285 (contrib/init: (OpenRC) use -startupnotify to wait for startup completion by whitslack)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  6. whitslack closed this on Jan 14, 2022

  7. whitslack deleted the branch on Jan 14, 2022
  8. DrahtBot locked this on Jan 14, 2023

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-10-06 16:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me