generally neaten up invocation of gunicorn - consolidate it to 1 invocation, with correct variables based on prod or not

This commit is contained in:
2024-11-16 00:07:12 +11:00
parent b928b2ff44
commit a7abf480f9

View File

@@ -1,11 +1,15 @@
#!/bin/bash #!/bin/bash
if [ "$FLASK_ENV" == "production" ]; then if [ "$FLASK_ENV" == "production" ]; then
sudo -u pybook ENV=${ENV} gunicorn --bind=0.0.0.0:80 --timeout 300 --workers=2 --threads=2 main:app --env FLASK_ENV="production" --error-logfile /code/gunicorn.error.log --access-logfile /code/gunicorn.log --capture-output --enable-stdio-inheritance export WORKERS=2
export THREADS=2
else else
cd /pybook_mapped_volume cd /pybook_mapped_volume
sudo -u pybook ENV=${ENV} gunicorn --bind=0.0.0.0:80 --timeout 300 --workers=1 --threads=1 main:app --env FLASK_ENV="$FLASK_ENV" --error-logfile ./gunicorn.error.log --access-logfile ./gunicorn.log --capture-output --enable-stdio-inheritance --reload export WORKERS=1
export THREADS=1
fi fi
# just in case it fails
sudo -u pybook gunicorn --bind=0.0.0.0:80 --timeout 300 --workers=$WORKERS --threads=$THREADS main:app --env FLASK_ENV="$FLASK_ENV" --error-logfile gunicorn.error.log --access-logfile gunicorn.log --capture-output --enable-stdio-inheritance
# just in case it fails this keeps the container up so you can check gunicorn logs
sleep 99999 sleep 99999