Skip to content

Instantly share code, notes, and snippets.

@foxmask
Created November 23, 2016 10:11
Show Gist options
  • Save foxmask/5023d93e14c61e582d509a354e086520 to your computer and use it in GitHub Desktop.
Save foxmask/5023d93e14c61e582d509a354e086520 to your computer and use it in GitHub Desktop.
#!/bin/bash
source $(dirname $0)/init.cfg
echo "Starting Gunicorn for $NAME"
exec ../bin/gunicorn ${DJANGO_WSGI_MODULE}:application \
--name $NAME \
--workers $NUM_WORKERS \
--user=$USER --group=$GROUP \
--log-level=$LOG_LEVEL \
--bind=$IP:$PORT \
--access-logfile $ACCESSFILE --error-logfile $ERRORFILE
NAME="th" # Name of the application
DJANGODIR=/home/trigger-happy/th/ # Django project directory
USER=foxmask # the user to run as
GROUP=foxmask # the group to run as
NUM_WORKERS=1 # how many worker processes should Gunicorn spawn
DJANGO_SETTINGS_MODULE=th.settings # which settings file should Django use
DJANGO_WSGI_MODULE=th.wsgi # WSGI module name
IP=127.0.0.1
PORT=8080
#LOG
LOGDIR=/home/trigger-happy/logs/
#LOG_LEVEL=DEBUG
LOG_LEVEL=INFO
ERRORFILE="$LOGDIR$NAME-error.log"
ACCESSFILE="$LOGDIR$NAME-access.log"
HTTPS=on
# Activate the virtual environment
cd $DJANGODIR
source ../bin/activate
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
export PYTHONPATH=$DJANGODIR:$PYTHONPATH
@foxmask
Copy link
Author

foxmask commented Nov 10, 2017

quand on rajoute le timeout et le worker class à gunicorn

#!/bin/bash
source $(dirname $0)/init.cfg

echo "Starting Gunicorn for $NAME"

exec ../bin/gunicorn ${DJANGO_WSGI_MODULE}:application \
  --name $NAME \
  --workers $NUM_WORKERS \
  --user=$USER --group=$GROUP \
  --log-level=$LOG_LEVEL \
  --bind=$IP:$PORT \
  --access-logfile $ACCESSFILE --error-logfile $ERRORFILE
  --timeout $TIMEOUT
  --worker-class $WORKER_CLASS

mais que ca timeout toujours autant et que le worker n'est pas le bon
"Using worker: sync"

comme ca c'est mieux, en evitant de config ca tard la nuit :)

#!/bin/bash
source $(dirname $0)/init.cfg

echo "Starting Gunicorn for $NAME"

exec ../bin/gunicorn ${DJANGO_WSGI_MODULE}:application \
  --name $NAME \
  --workers $NUM_WORKERS \
  --user=$USER --group=$GROUP \
  --log-level=$LOG_LEVEL \
  --bind=$IP:$PORT \
  --access-logfile $ACCESSFILE --error-logfile $ERRORFILE \
  --timeout $TIMEOUT \
  --worker-class $WORKER_CLASS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment