summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Levsen <holger@layer-acht.org>2017-04-26 12:48:03 +0200
committerHolger Levsen <holger@layer-acht.org>2017-04-26 12:48:03 +0200
commit6448e85c7d7e36f78443591e76c33bb9446ceb36 (patch)
treebb58a32cd7ccbc2a71e7cee199fe1519848b7675
parent1f4e428d123487214a8ce421fbbaf07fccde72ba (diff)
downloadjenkins.debian.net-6448e85c7d7e36f78443591e76c33bb9446ceb36.tar.xz
reproducible Debian: add checks to prevent concurrent runs and from running when service is stopped
Signed-off-by: Holger Levsen <holger@layer-acht.org>
-rwxr-xr-xbin/reproducible_build_service_worker.sh13
1 files 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 )