Fix issue #614: restart queue/evaluator on sufficient disk space available.
Only try to stop the service if it is currently running.
Use named variables and added restarting message.
5IMKIE625LYUDGIDLHTX2JFGIFUEAMVAND76KVJG34VOATMQXFZAC
S3ONTQMPUAGBDCAX2TZSWI4TEHWK3EI5G74TXDJJ6SWNCEVZ6NLAC
TTZ26BJQKIASUK7MT6KGQOIOOHEYWNV4UASO2ZQWGK4ADGK6SR6QC
D3MDJONYWWNXVVZDKTPDQE2H2HGMF263LXKT57B2GYCOXNM3PPOQC
KMPLMG7TDEVQVZGRXQKG66G6P7LUDELSKRFUO557PQ4WZQI3SBAQC
3FTM52B2FQBNZ4GANKVIFALA757VXJEP3K4QLVJYQSDWIK7IP5VAC
ZTF2YQGCUX4ASNQRCXCUZCU74IFN4WDIX67PXXR4RDL54IIDJJFQC
ZYEFL36QOB6KUR276RRT4PSAK7HWUJ6TLLZBEZM7SSGUX2WQTMZQC
if [ $(($(stat -f -c '%a' /nix/store) * $(stat -f -c '%S' /nix/store))) -lt $((${toString cfg.minimumDiskFree} * 1024**3)) ]; then
echo "stopping Hydra queue runner due to lack of free space..."
systemctl stop hydra-queue-runner
fi
if [ $(($(stat -f -c '%a' /nix/store) * $(stat -f -c '%S' /nix/store))) -lt $((${toString cfg.minimumDiskFreeEvaluator} * 1024**3)) ]; then
echo "stopping Hydra evaluator due to lack of free space..."
systemctl stop hydra-evaluator
fi
spaceleft=$(($(stat -f -c '%a' /nix/store) * $(stat -f -c '%S' /nix/store)))
spacestopstart() {
service=$1
minFreeGB=$2
if [ $spaceleft -lt $(($minFreeGB * 1024**3)) ]; then
if [ $(systemctl is-active $service) == active ]; then
echo "stopping $service due to lack of free space..."
systemctl stop $service
date > /var/lib/hydra/.$service-stopped-minspace
fi
else
if [ $spaceleft -gt $(( ($minFreeGB + 10) * 1024**3)) -a \
-r /var/lib/hydra/.$service-stopped-minspace ] ; then
rm /var/lib/hydra/.$service-stopped-minspace
echo "restarting $service due to newly available free space..."
systemctl start $service
fi
fi
}
spacestopstart hydra-queue-runner ${toString cfg.minimumDiskFree}
spacestopstart hydra-evaluator ${toString cfg.minimumDiskFreeEvaluator}