Support for a bitcoind 'ready' file to indicate startup is complete. #15500

pull murrayn wants to merge 1 commits into bitcoin:master from murrayn:ready_file changing 1 files +46 −7
  1. murrayn commented at 6:52 AM on February 28, 2019: contributor

    Please see the discussion of #15367 for detailed rationale. Essentially, the idea is to indicate, via creation of a file, that bitcoind is not only running but ready to actually use. This should provide a convenient way for scripts to reliably start bitcoind, wait for it to become ready, and then subsequently start any other services (e.g. lnd) that depend on it.

    This PR also adds a -ready argument for specifying the name of the ready file (default: $DATADIR/.ready)

  2. fanquake added the label Utils/log/libs on Feb 28, 2019
  3. DrahtBot commented at 7:00 AM on February 28, 2019: member

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #15367 (feature: Added ability for users to add a startup command by benthecarman)
    • #15218 (validation: Flush state after initial sync by andrewtoth)

    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.

  4. in src/init.cpp:233 in 53fb7f72ab outdated
     229 | @@ -194,6 +230,7 @@ void Interrupt()
     230 |  void Shutdown(InitInterfaces& interfaces)
     231 |  {
     232 |      LogPrintf("%s: In progress...\n", __func__);
     233 | +    RemoveFile(GetReadyFile());
    


    luke-jr commented at 9:15 AM on February 28, 2019:

    If the computer crashes, the file won't get deleted...


    murrayn commented at 9:10 AM on March 1, 2019:

    Fair point, but the external command approach would likely have the same limitation. Perhaps we could remove any existing ready file early in AppInitMain() (or earlier) to mitigate this?

    I am very uncomfortable with adding the ability to exec() external programs. It just feels like an attack vector.


    luke-jr commented at 10:42 AM on March 3, 2019:

    -blocknotify and -walletnotify already exist.

  5. luke-jr changes_requested
  6. luke-jr commented at 9:15 AM on February 28, 2019: member

    I think executing a command is a better approach. You can then have it execute echo >/path/to/.ready if you like.

  7. practicalswift commented at 10:26 AM on February 28, 2019: contributor

    @murrayn Is it worth writing the PID to the readiness file to allow the consumer to verify that the file is not stale?

    Would it be worth to allow for also the "waiting for startup" scenario by writing to say .bitcoind-state.initializing immediately on startup-up and then rename it to .bitcoind-state.ready when the initialization is done?

  8. in src/init.cpp:145 in 53fb7f72ab outdated
     140 | +        return InitError(strprintf(_("Unable to create the ready status file '%s': %s"),
     141 | +                   GetReadyFile().string(), std::strerror(errno)));
     142 | +    }
     143 | +}
     144 | +
     145 | +static bool RemoveFile(fs::path file)
    


    practicalswift commented at 8:42 PM on February 28, 2019:

    Should be const ref? :-)


    murrayn commented at 8:44 AM on March 1, 2019:

    Yes, fixed.

  9. murrayn force-pushed on Mar 1, 2019
  10. murrayn commented at 8:52 AM on March 1, 2019: contributor

    @practicalswift Thanks for the comments. I did consider both of those approaches. But the PID is already available in bitcoind.pid, so doing so here seems redundant. I also considered having a 'status' file of some type, instead of 'ready', but I think the only interesting status is likely to be 'ready' anyway.

  11. murrayn force-pushed on Mar 1, 2019
  12. murrayn force-pushed on Mar 1, 2019
  13. promag commented at 4:51 PM on March 3, 2019: member

    NACK, sorry.

    the idea is to indicate, via creation of a file, that bitcoind is not only running but ready to actually use

    I'd say just use it. A good script should handle retrying, not only when it's starting up, but also when it crashed or it's being updated or something. This approach also works if the other service is not in the same host, which this PR can't handle. See the test framework, it checks if it's ready by calling getblockcount a couple of times: https://github.com/bitcoin/bitcoin/blob/2d46f1be0c3c8b7287aa1f62bb1f5b4a8d00ff6e/test/functional/test_framework/test_node.py#L206-L219

  14. dongcarl commented at 2:38 AM on March 4, 2019: member

    @murrayn I think a better modification is perhaps adding support for sd_notify (behind a configure flag) that would tell systemd when things are ready. Or doing something like a systemd socket configuration. But of course all of those are systemd specific.

  15. Support for a bitcoind 'ready' file (default: '.ready') 94fd16b0e7
  16. murrayn force-pushed on Mar 4, 2019
  17. murrayn commented at 6:09 AM on March 28, 2019: contributor

    Doesn't seem to be much traction for this, so I'll close it.

  18. murrayn closed this on Mar 28, 2019

  19. MarcoFalke locked this on Dec 16, 2021
  20. murrayn deleted the branch on Feb 17, 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: 2026-04-13 15:15 UTC

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