30 lines
636 B
Bash
30 lines
636 B
Bash
#!/bin/bash
|
|
PYTHON=python3
|
|
SQLITE=sqlite3
|
|
|
|
export FLASK_DATAFOLDER="/data"
|
|
export FLASK_DB="/data/flees.db"
|
|
export INTERNAL_PORT="${INTERNAL_PORT:-5000}"
|
|
export SERVER=gunicorn
|
|
export PID="flees.pid"
|
|
export WORKERS
|
|
export TIMEOUT
|
|
|
|
if [[ $( stat -c %u /data ) -ne $( id -u ) ]]; then
|
|
echo User id and /data folder owner do not match
|
|
printf 'UID: %s\nFolder: %s\n' $( id -u ) $( stat -c %u /data )
|
|
exit 1
|
|
fi
|
|
|
|
set -eu
|
|
. /opt/venv/bin/activate
|
|
sh ./init_db.sh "$FLASK_DB"
|
|
|
|
exec "$SERVER" \
|
|
-w $WORKERS \
|
|
--timeout $TIMEOUT \
|
|
--pid="$PID" \
|
|
-b 0.0.0.0:$INTERNAL_PORT \
|
|
'app:app' \
|
|
2>&1 | tee -a /data/flees.log
|