banlist: don't wait in preStart until bitcoind is ready
preStart is meant for short-run scripts, but bitcoind can take a long time until it accepts commands, especially on low-powered systems. Fixes #122
This commit is contained in:
parent
d87c50a305
commit
d64156e485
|
@ -272,32 +272,18 @@ in {
|
||||||
wantedBy = [ "bitcoind.service" ];
|
wantedBy = [ "bitcoind.service" ];
|
||||||
bindsTo = [ "bitcoind.service" ];
|
bindsTo = [ "bitcoind.service" ];
|
||||||
after = [ "bitcoind.service" ];
|
after = [ "bitcoind.service" ];
|
||||||
preStart = ''
|
script = ''
|
||||||
set +e
|
cd ${cfg.cli}/bin
|
||||||
echo "Checking that bitcoind is up"
|
# Poll until bitcoind accepts commands. This can take a long time.
|
||||||
# Give bitcoind time to create pid file
|
while ! ./bitcoin-cli getnetworkinfo &> /dev/null; do
|
||||||
sleep 2
|
sleep 1
|
||||||
while true
|
|
||||||
do
|
|
||||||
'${cfg.package}'/bin/bitcoin-cli -datadir='${cfg.dataDir}' getnetworkinfo > /dev/null
|
|
||||||
if [ "$?" -eq 0 ]; then
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
sleep 1
|
|
||||||
done
|
done
|
||||||
|
echo "Importing node banlist..."
|
||||||
|
. ${./banlist.cli.txt}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
User = "${cfg.user}";
|
User = "${cfg.user}";
|
||||||
Group = "${cfg.group}";
|
Group = "${cfg.group}";
|
||||||
script = ''
|
|
||||||
echo "Importing node banlist..."
|
|
||||||
cd ${cfg.cli}/bin
|
|
||||||
. ${./banlist.cli.txt}
|
|
||||||
'';
|
|
||||||
|
|
||||||
# Permission for preStart
|
|
||||||
PermissionsStartOnly = "true";
|
|
||||||
} // nix-bitcoin-services.defaultHardening
|
} // nix-bitcoin-services.defaultHardening
|
||||||
// nix-bitcoin-services.allowTor;
|
// nix-bitcoin-services.allowTor;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user