add seepark_webapp
authorgregor herrmann <gregor@toastfreeware.priv.at>
Wed, 12 Sep 2018 21:47:44 +0000 (23:47 +0200)
committergregor herrmann <gregor@toastfreeware.priv.at>
Wed, 12 Sep 2018 21:47:44 +0000 (23:47 +0200)
script to start/stop seepark webapp (i.e. waitress)

seepark_webapp [new file with mode: 0755]

diff --git a/seepark_webapp b/seepark_webapp
new file mode 100755 (executable)
index 0000000..c7a57fa
--- /dev/null
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+die() {
+       echo "$1" >&2
+       usage
+       exit 1
+}
+
+usage() {
+       echo "Usage: ./$ME <start|stop|restart>." >&2
+}
+
+ME=$(basename $0)
+DIR=$(dirname $0)
+ARG=$1
+
+set -eu
+
+[ -n "$ARG" ] || die "Missing argument."
+
+start() {
+       cd "$DIR/web"
+       SEEPARKINI=../../seewasser.ini waitress-serve --listen=[::1]:8765 'seepark_web:app' &
+}
+
+stop() {
+       killall waitress-serve
+}
+
+case "$ARG" in
+       start)
+               start
+               ;;
+       stop)
+               stop
+               ;;
+       restart)
+               stop
+               sleep 1
+               start
+               ;;
+       help|-h|--help)
+               usage
+               ;;
+       *)
+               die "Unknown argument '$ARG'." >&2
+               ;;
+esac
+
+exit $?