-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow restarting
openqa-webui-daemon
without downtime
* Allow restarting `openqa-webui-daemon` without downtime by sending SIGHUP to the process or reloading the systemd unit `openqa-webui.service` * Start the Mojolicious application with `reuse=1` as mentioned on https://docs.mojolicious.org/Mojolicious/Guides/Cookbook#Zero-downtime-software-upgrades * Note that other services are not covered but those are also not user facing or retried and thus not required * See https://progress.opensuse.org/issues/162533
- Loading branch information
Showing
3 changed files
with
38 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,35 @@ | ||
#!/bin/sh -e | ||
# Our API commands are very expensive, so the default timeouts are too tight | ||
exec "$(dirname "$0")"/openqa prefork -m production --proxy -i 100 -H 900 -w 30 -c 1 -G 800 "$@" | ||
#!/bin/bash | ||
set -e | ||
|
||
pid= | ||
pid_idx=0 | ||
pid_dir=${OPENQA_BASEDIR:-/var/lib}/openqa/webui | ||
openqa_args=("$@") | ||
openqa_dir=$(dirname "$0") | ||
|
||
function start_service { | ||
# keep track of the previous and next PID | ||
pid_last=$pid | ||
pid_file=$pid_dir/prefork-$pid_idx.pid | ||
pid_idx=$(((pid_idx + 1) % 2)) | ||
rm -f "$pid_file" | ||
|
||
# start openQA in the background | ||
# note: Our API commands are very expensive, so the default timeouts are too tight. | ||
"$openqa_dir"/openqa prefork -m production --proxy -i 100 -H 900 -w 30 -c 1 -G 800 -P "$pid_file" "${openqa_args[@]}" & | ||
pid=$! | ||
|
||
# wait until openQA is ready to accept requests by waiting for its PID file | ||
while [[ ! -e $pid_file ]] && [[ -e /proc/$pid ]]; do sleep 1; done | ||
|
||
# terminate a previously started openQA instance | ||
[[ $pid_last ]] && kill -s TERM "$pid_last" | ||
|
||
# keep running until openQA terminates (with the "wait"-builtin so bash can handle SIGHUP) | ||
wait "$pid" | ||
} | ||
|
||
# start service now and restart it gracefully when we receive SIGHUP | ||
# see https://docs.mojolicious.org/Mojolicious/Guides/Cookbook#Zero-downtime-software-upgrades | ||
trap start_service SIGHUP | ||
start_service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters