From 6448e85c7d7e36f78443591e76c33bb9446ceb36 Mon Sep 17 00:00:00 2001 From: Holger Levsen Date: Wed, 26 Apr 2017 12:48:03 +0200 Subject: reproducible Debian: add checks to prevent concurrent runs and from running when service is stopped Signed-off-by: Holger Levsen --- bin/reproducible_build_service_worker.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/bin/reproducible_build_service_worker.sh b/bin/reproducible_build_service_worker.sh index b057b77a..9748a6c5 100755 --- a/bin/reproducible_build_service_worker.sh +++ b/bin/reproducible_build_service_worker.sh @@ -20,8 +20,17 @@ common_init "$@" . /srv/jenkins/bin/reproducible_common.sh while true ; do - # TODO - # - test here if the builder service is actually running… + RUNNING=$(ps fax|grep -v grep|grep "$0 $1 ") + if [ -z "$RUNNING" ] ; then + echo "$(date --utc) - '$0 $1' already running, thus stopping this." + break + fi + SERVICE="reproducible_build@startup.service" + RUNNING=$(systemctl show $SERVICE|grep ^SubState|cut -d "=" -f2) + if [ "$RUNNING" != "running" ] ; then + echo "$(date --utc) - '$SERVICE' not running, thus stopping this." + break + fi # sleep up to 2.3 seconds (additionally to the random sleep reproducible_build.sh does anyway) /bin/sleep $(echo "scale=1 ; $(shuf -i 1-23 -n 1)/10" | bc ) -- cgit v1.2.3-70-g09d2