Skip to content

Commit 769dd1e

Browse files
committed
Merge bitcoin/bitcoin#25975: contrib/init: Better systemd integration
689a65d contrib/init: Better systemd integration (Carl Dong) Pull request description: ``` 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. Note that we currently don't allow multiple startupnotify 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; mycommandhere' ``` ACKs for top commit: real-or-random: ACK 689a65d tested this service file with 25.0 Tree-SHA512: 9a52ad5cf25886c0d8dabc986d8920602a056db25875b5edd910b387043b78bb78c76d6df82e6e322e3be3bfd5c35c80721cbc8308cec946060bd7586820e9c6
2 parents a2e111b + 689a65d commit 769dd1e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

contrib/init/bitcoind.service

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ After=network-online.target
1818
Wants=network-online.target
1919

2020
[Service]
21-
ExecStart=/usr/bin/bitcoind -daemonwait \
22-
-pid=/run/bitcoind/bitcoind.pid \
21+
ExecStart=/usr/bin/bitcoind -pid=/run/bitcoind/bitcoind.pid \
2322
-conf=/etc/bitcoin/bitcoin.conf \
24-
-datadir=/var/lib/bitcoind
23+
-datadir=/var/lib/bitcoind \
24+
-startupnotify='systemd-notify --ready' \
25+
-shutdownnotify='systemd-notify --stopping'
2526

2627
# Make sure the config directory is readable by the service user
2728
PermissionsStartOnly=true
@@ -30,8 +31,10 @@ ExecStartPre=/bin/chgrp bitcoin /etc/bitcoin
3031
# Process management
3132
####################
3233

33-
Type=forking
34+
Type=notify
35+
NotifyAccess=all
3436
PIDFile=/run/bitcoind/bitcoind.pid
37+
3538
Restart=on-failure
3639
TimeoutStartSec=infinity
3740
TimeoutStopSec=600

0 commit comments

Comments
 (0)