forgejo-runner.sh reload must wait for the daemon to stop

This commit is contained in:
Earl Warren 2023-10-04 19:20:35 +02:00
parent 65714b4555
commit 15a46373fb
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00

View file

@ -32,13 +32,17 @@ function register() {
function run() {
rm -f forgejo-runner.log
daemon --chdir=$(pwd) --unsafe --env="TERM=$TERM" --env="HOME=$HOME" --env="PATH=$PATH" --env="USER=$USER" --env="TERM=dumb" --env="USERNAME=$USERNAME" --env="LANG=$LANG" --pidfile=$(pwd)/forgejo-runner-pid --errlog=$(pwd)/forgejo-runner.log --output=$(pwd)/forgejo-runner.log -- forgejo-runner --config $FORGEJO_RUNNER_CONFIG daemon
daemon --chdir=$(pwd) --unsafe \
--env="TERM=$TERM" --env="HOME=$HOME" --env="PATH=$PATH" --env="USER=$USER" --env="TERM=dumb" --env="USERNAME=$USERNAME" --env="LANG=$LANG" \
--pidfile=$(pwd)/forgejo-runner-pid --errlog=$(pwd)/forgejo-runner.log --output=$(pwd)/forgejo-runner.log -- \
forgejo-runner --config $FORGEJO_RUNNER_CONFIG daemon
sleep 1
cat forgejo-runner.log
}
function reload() {
teardown
rm -f forgejo-runner.log
run
}
@ -53,11 +57,26 @@ function setup() {
run
}
function teardown() {
if test -f forgejo-runner-pid ; then
kill -TERM $(cat forgejo-runner-pid)
rm -f forgejo-runner-pid
function stop_daemon() {
local daemon=$1
local DIR=.
if test -f $DIR/$daemon-pid ; then
local pid=$(cat $DIR/$daemon-pid)
kill -TERM $pid
pidwait $pid || true
for delay in 1 1 2 2 5 5 ; do
if ! test -f $DIR/$daemon-pid ; then
break
fi
sleep $delay
done
! test -f $DIR/$daemon-pid
fi
}
function teardown() {
stop_daemon forgejo-runner
}
"$@"