#!/bin/bash # serve.sh start|stop|restart -- webgym server on :8811, tracked by pid file (never pkill by pattern) D=$(cd "$(dirname "$0")" && pwd); PIDF=${GYM_PIDFILE:-/tmp/webgym.pid}; LOG=${GYM_LOG:-/tmp/webgym.log} stop() { [ -f $PIDF ] && kill $(cat $PIDF) 2>/dev/null; rm -f $PIDF; sleep 0.5; } start() { nohup $D/../../.venv/bin/python $D/app.py 8811 > $LOG 2>&1 & echo $! > $PIDF; sleep 1.5; curl -s --noproxy '*' -o /dev/null -w "webgym %{http_code}\n" http://127.0.0.1:8811/t/flight/1; } case "$1" in start) start;; stop) stop;; restart) stop; start;; esac