-
Notifications
You must be signed in to change notification settings - Fork 37.8k
contrib/init: Better systemd integration #25975
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
dongcarl
commented
Sep 1, 2022
Concept ACK |
Related: #22372 |
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsNo conflicts as of last run. |
Anything else needed here? |
Someone to actually sanity-check / test / review / leave an ACK? I don't use systemd, so can't test, and don't generally know if this is an improvement or not. Looks like it at least partially reverts #21418, which was done in combination with #21007; where Does this change break / compormise that behaviour? |
Will try to look at these proposed changes with my RaspiBolt, which uses systemd (although with custom systemd unit file, but it is similar). |
I think what laanwj was saying there was that if we had integrated So that's why we started using However, IIRC, in using With the introduction of Sidenote: There's currently no way I can find to tell Sidenote 2: While it doesn't make sense to modify |
The feature request didn't seem to attract much attention in the past. Also, the issue seems not important enough right now to keep it sitting around idle in the list of open issues. Closing due to lack of interest. Pull requests with improvements are always welcome. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK mod nits
This is very useful for systemd users. The changes match systemd docs and I tested that process management and logging works as intended.
@achow101 Can you reopen this?
One minor issue: This means what (with default config), we have log output both in systemd's journal and in the log file. In principle, it may make sense to also pass -nodebuglogfile
, but I'm not sure if this is really what we want because it means that the user can't override this option in the config file anymore... Maybe a Changelog entry should be added, recommending systemd users to consider disabling writing logs to a file.
A more sophisticated solution would be to add a --systemd-notify
command line option, that sets modifies the defaults of startupnotify
, shutdownnotify
, and debuglogfile
(or even better avoids the problem that users who want to use further startup commands need to modify the systemd unit file). But I'm not convinced that adding this option is worth the hassle. It's probably good to have all systemd-specific code just in this unit file here. Anyway, this PR is clearly an improvement for systemd users, so even if --systemd-notify
is a good idea for the future, it should not hold up this PR.
1. Make logs available to journalctl (systemd's logging system) by not specifying -daemonwait, which rightfully has its own set of stdout and stderr descriptors (a user invoking with -daemonwait on the command line should not see any logs). It makes more sense not to daemonize in the systemd context anyway. 2. Make systemd aware of when bitcoind is started and in steady state by specifying -startupnotify='systemd-notify --ready' and Type=notify. NotifyAccess=all is necessary so that the spawned thread for startupnotify is allowed to inform systemd of bitcoind's readiness. Note that NotifyAccess=exec won't work because it only allows sd_notify readiness signalling from Exec*= declarations in the .service file. 3. Also make systemd aware of when bitcoind is stopping by specifying -shutdownnotify='systemd-notify --stopping' Note that we currently don't allow multiple *notify commands, but users can override it in systemd via: # systemctl edit bitcoind By specifying something like: [Service] ExecStart=/usr/bin/bitcoind -pid=/run/bitcoind/bitcoind.pid \ -conf=/etc/bitcoin/bitcoin.conf \ -datadir=/var/lib/bitcoind \ -startupnotify='systemd-notify --ready; mystartupcommandhere' \ -shutdownnotify='systemd-notify --stopping; myshutdowncommandhere'
42bcabb
to
689a65d
Compare
Pushed 689a65d: |
I think whether or not to to add a As in: Does a user of In any case, I think we can leave that discussion for another time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 689a65d tested this service file with 25.0
This is great. Can you (or someone else) make a release note? I certainly prefer to keep using my debug.log file. I generally only use journalctl if there's a problem starting a service (or to see if indeed got the right version after an update). |
Remove .service file patch since it's now in the release See: bitcoin/bitcoin#25975