0

I've been trying to apply some changes to my Flask app by reloading both gunicorn and supervisor. I've already followed several tutorials using scripts and packages like rainbow-saddle. Nothing seems to work, not even rebooting the entire server.

The flask app is being run in a virtual environment and I suspect this may be the problem.

The following is the startup script for gunicorn and the flask app.

#!/bin/bash

NAME="Simon"                                  
FLASKDIR=/var/www/Simon            
SOCKFILE=/var/www/Simon/simon.sock  
USER=glen                                        
GROUP=glen                                    
NUM_WORKERS=3                                    
FLASK_SETTINGS_MODULE=config.py          
FLASK_WSGI_MODULE=Simon_wsgi.wsgi                    
echo "Starting $NAME as `whoami`"

# Activate the virtual environment
cd $FLASKDIR
source Simon/bin/activate
export FLASK_SETTINGS_MODULE=$FLASK_SETTINGS_MODULE
export PYTHONPATH=$FLASKDIR:$PYTHONPATH

# Create the run directory if it doesn't exist
RUNDIR=$(dirname $SOCKFILE)
test -d $RUNDIR || mkdir -p $RUNDIR

exec gunicorn Simon:simon \
  --name $NAME \
  --workers $NUM_WORKERS \
  --user=$USER --group=$GROUP \
  --bind=unix:$SOCKFILE \
  --log-level=debug \
  --pid=$FLASKDIR/gunicorn.pid
  --log-file=$FLASKDIR/logs/gunicorn.log
  --chdir=/var/www/Simon

This is a snippet of output from the supervisor log.

2017-08-20 19:31:56,789 WARN received SIGHUP indicating restart request
2017-08-20 19:31:56,790 INFO waiting for simon to die
2017-08-20 19:31:56,886 INFO stopped: simon (exit status 0)
2017-08-20 19:31:56,890 INFO supervisord started with pid 1438
2017-08-20 19:31:57,892 INFO spawned: 'simon' with pid 2751
2017-08-20 19:31:59,308 INFO success: simon entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

I've already tried using a .pid for both supervisor and gunicorn to kill -HUP them. Nothing I do seems to refresh the code that is being used.

EDIT: the conf at /etc/supervisor/supervisord.conf

[supervisord]
logfile=/var/www/Simon/logs/supervisord.log
loglevel=info


[program:simon]
command= bash /var/www/Simon/Simon/bin/gunicorn_start.bash Simon:simon --bind 0.0.0.0
directory=/var/www/Simon
user=glen
autostart=true
autorestart=true
redirect_stderr=true
priority=500
;

[program:simonreload]
autostart=true
autorestart=false
directory=/tmp
command=watchmedo shell-command --patterns="*.py;*.html;*.css;*.js" --recursive -HUP $(cat /var/www/Simon/supervisord.pid)'
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
smallpants
  • 460
  • 7
  • 20

0 Answers0