#!/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 exit 1 } usage() { echo "Usage: ./$ME ." >&2 } set -eu [ -n "$ARG" ] || die "Missing argument." start() { /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() { /sbin/start-stop-daemon --stop --remove-pidfile --pidfile "$PIDFILE" } case "$ARG" in start) start ;; stop) stop ;; status) status ;; restart) stop sleep 1 start ;; help|-h|--help) usage ;; *) die "Unknown argument '$ARG'." >&2 ;; esac exit $?