From a7abf480f9fc924b5df9416fc7f0dd6943034e04 Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Sat, 16 Nov 2024 00:07:12 +1100 Subject: [PATCH] generally neaten up invocation of gunicorn - consolidate it to 1 invocation, with correct variables based on prod or not --- wrapper.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/wrapper.sh b/wrapper.sh index ac5aebf..ee7d910 100755 --- a/wrapper.sh +++ b/wrapper.sh @@ -1,11 +1,15 @@ #!/bin/bash - 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 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 -# 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