banlist: simplify unit, bind to bitcoind, fix wantedBy
Type = "simple" is the default unit type. Being wanted by bitcoind instead of a system target is more appropriate. By binding to bitcoind, the service is automatically stopped when bitcoind exits. This eliminates the bitcoind liveness check in preStart.
This commit is contained in:
parent
39885d37c1
commit
d87c50a305
@ -269,9 +269,9 @@ in {
|
|||||||
# wget https://people.xiph.org/~greg/banlist.cli.txt
|
# wget https://people.xiph.org/~greg/banlist.cli.txt
|
||||||
systemd.services.bitcoind-import-banlist = {
|
systemd.services.bitcoind-import-banlist = {
|
||||||
description = "Bitcoin daemon banlist importer";
|
description = "Bitcoin daemon banlist importer";
|
||||||
requires = [ "bitcoind.service" ];
|
wantedBy = [ "bitcoind.service" ];
|
||||||
|
bindsTo = [ "bitcoind.service" ];
|
||||||
after = [ "bitcoind.service" ];
|
after = [ "bitcoind.service" ];
|
||||||
wantedBy = [ "multi-user.target" ];
|
|
||||||
preStart = ''
|
preStart = ''
|
||||||
set +e
|
set +e
|
||||||
echo "Checking that bitcoind is up"
|
echo "Checking that bitcoind is up"
|
||||||
@ -279,12 +279,6 @@ in {
|
|||||||
sleep 2
|
sleep 2
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
pid=$(cat ${pidFile})
|
|
||||||
${pkgs.ps}/bin/ps -p "$pid" > /dev/null
|
|
||||||
if [ "$?" -ne 0 ]; then
|
|
||||||
echo "bitcoind already exited"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
'${cfg.package}'/bin/bitcoin-cli -datadir='${cfg.dataDir}' getnetworkinfo > /dev/null
|
'${cfg.package}'/bin/bitcoin-cli -datadir='${cfg.dataDir}' getnetworkinfo > /dev/null
|
||||||
if [ "$?" -eq 0 ]; then
|
if [ "$?" -eq 0 ]; then
|
||||||
break
|
break
|
||||||
@ -294,7 +288,6 @@ in {
|
|||||||
'';
|
'';
|
||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "simple";
|
|
||||||
User = "${cfg.user}";
|
User = "${cfg.user}";
|
||||||
Group = "${cfg.group}";
|
Group = "${cfg.group}";
|
||||||
script = ''
|
script = ''
|
||||||
|
Loading…
Reference in New Issue
Block a user