X-Git-Url: https://git.toastfreeware.priv.at/philipp/winterrodeln/wrfeed.git/blobdiff_plain/bed6ce492e2625969cae28a4210680cd7436170f..1cf0f22b88ee56df00e5a280c0f99232f1063d7a:/wrfeed_webapp.sh diff --git a/wrfeed_webapp.sh b/wrfeed_webapp.sh index 42aca17..9275985 100755 --- a/wrfeed_webapp.sh +++ b/wrfeed_webapp.sh @@ -1,5 +1,15 @@ #!/bin/sh +ME=$(basename $0) +DIR=$(dirname $0) +ARG=$1 +APPDIR=$DIR +PORT=8766 +USER=philipp +PIDFILE=/home/philipp/.wrfeed-webapp.pid +export WRFEED_SETTINGS=/home/philipp/daten/Winterrodeln/winterrodeln/wrfeed/wrfeed/development.cfg + + die() { echo "$1" >&2 usage @@ -7,24 +17,42 @@ die() { } usage() { - echo "Usage: ./$ME ." >&2 + echo "Usage: ./$ME ." >&2 } -ME=$(basename $0) -DIR=$(dirname $0) -ARG=$1 - set -eu [ -n "$ARG" ] || die "Missing argument." start() { - cd "$DIR" - WRFEED_SETTINGS=development.cfg waitress-serve --listen=[::1]:8766 'wrfeed:app' & + /sbin/start-stop-daemon --chuid $USER --chdir "$APPDIR" --make-pidfile --background --pidfile $PIDFILE --exec /usr/bin/waitress-serve --start -- --listen=[::1]:$PORT 'wrfeed:app' +} + +status() { + set +e + /sbin/start-stop-daemon --status --pidfile "$PIDFILE" + case "$?" in + 0) + echo running + ;; + 1) + echo not running but PID file exists + ;; + 3) + echo not running + ;; + 4) + echo unable to determine status + ;; + *) + die "unknown status" + ;; + esac } + stop() { - killall waitress-serve + /sbin/start-stop-daemon --stop --remove-pidfile --pidfile "$PIDFILE" } case "$ARG" in @@ -34,6 +62,9 @@ case "$ARG" in stop) stop ;; + status) + status + ;; restart) stop sleep 1