aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2023-05-29 13:43:27 +0100
committerfanquake <fanquake@gmail.com>2023-05-29 13:43:42 +0100
commit769dd1e826fa9b3b6385240b9dfbd3a71858584b (patch)
treeb8282324d316be37a18ce02c39975cb21b659a46 /contrib
parenta2e111b8a3d17e328eba6111f6c9138543255f3d (diff)
parent689a65d878638ae67b07f111dd77ea3c624e4f58 (diff)
downloadbitcoin-769dd1e826fa9b3b6385240b9dfbd3a71858584b.tar.xz
Merge bitcoin/bitcoin#25975: contrib/init: Better systemd integration
689a65d878638ae67b07f111dd77ea3c624e4f58 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 689a65d878638ae67b07f111dd77ea3c624e4f58 tested this service file with 25.0 Tree-SHA512: 9a52ad5cf25886c0d8dabc986d8920602a056db25875b5edd910b387043b78bb78c76d6df82e6e322e3be3bfd5c35c80721cbc8308cec946060bd7586820e9c6
Diffstat (limited to 'contrib')
-rw-r--r--contrib/init/bitcoind.service11
1 files changed, 7 insertions, 4 deletions
diff --git a/contrib/init/bitcoind.service b/contrib/init/bitcoind.service
index 93de353bb4..87da17f955 100644
--- a/contrib/init/bitcoind.service
+++ b/contrib/init/bitcoind.service
@@ -18,10 +18,11 @@ After=network-online.target
Wants=network-online.target
[Service]
-ExecStart=/usr/bin/bitcoind -daemonwait \
- -pid=/run/bitcoind/bitcoind.pid \
+ExecStart=/usr/bin/bitcoind -pid=/run/bitcoind/bitcoind.pid \
-conf=/etc/bitcoin/bitcoin.conf \
- -datadir=/var/lib/bitcoind
+ -datadir=/var/lib/bitcoind \
+ -startupnotify='systemd-notify --ready' \
+ -shutdownnotify='systemd-notify --stopping'
# Make sure the config directory is readable by the service user
PermissionsStartOnly=true
@@ -30,8 +31,10 @@ ExecStartPre=/bin/chgrp bitcoin /etc/bitcoin
# Process management
####################
-Type=forking
+Type=notify
+NotifyAccess=all
PIDFile=/run/bitcoind/bitcoind.pid
+
Restart=on-failure
TimeoutStartSec=infinity
TimeoutStopSec=600