From d87c50a30526fb75b2de225b42eba5c7a37de81e Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Tue, 12 Nov 2019 19:40:32 +0100 Subject: [PATCH] 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. --- modules/bitcoind.nix | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/modules/bitcoind.nix b/modules/bitcoind.nix index 6a5dac4..689ca4c 100644 --- a/modules/bitcoind.nix +++ b/modules/bitcoind.nix @@ -269,9 +269,9 @@ in { # wget https://people.xiph.org/~greg/banlist.cli.txt systemd.services.bitcoind-import-banlist = { description = "Bitcoin daemon banlist importer"; - requires = [ "bitcoind.service" ]; + wantedBy = [ "bitcoind.service" ]; + bindsTo = [ "bitcoind.service" ]; after = [ "bitcoind.service" ]; - wantedBy = [ "multi-user.target" ]; preStart = '' set +e echo "Checking that bitcoind is up" @@ -279,12 +279,6 @@ in { sleep 2 while true 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 if [ "$?" -eq 0 ]; then break @@ -294,7 +288,6 @@ in { ''; serviceConfig = { - Type = "simple"; User = "${cfg.user}"; Group = "${cfg.group}"; script = ''