0

When my server (centOS 7 hosted on a vagrant VM) reboots, my Python Flask application (served up by Gunicorn using nginx as a reverse proxy) throws internal server errors (according to the stack traces I'm getting, it can't find templated html files even...) until a sudo supervisorctl reload is issued. After this, the application runs just fine and my life is good but that won't do now will it?

I suspect a race condition (maybe between supervisor and gunicorn?). I tried adding a sleep to the command in the specific program's .ini file but this didn't help anything.

Has anyone else encountered something like this? If not, does anyone know of how to delay the start of the entire supervisor utility (not just one specific program)?

For reference, here's what the contents of my .ini file look like:

[program:test]
command=/bin/gunicorn -b localhost:8000 -w 2 the_app:app
directory=/var/www/test
user=vagrant
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true

Again, this works fine after supervisor is reloaded it just doesn't seem to start up correctly (presumably because of some kind of race condition).

For completeness: the addition of the sleep condition caused the .ini file to look like:

[program:test]
command=bash -c "sleep 10 && exec /bin/gunicorn -b localhost:8000 -w 2 the_app:app"
directory=/var/www/test
user=vagrant
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true

Aside from not fixing the problem (lol), this feels dirty so I strongly prefer not to do something like this.

Thanks in advance for any guidance.

codeAndStuff
  • 101
  • 1
  • 1
    Why have you used supervisord instead of [normal systemd units](https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-centos-7)? – Michael Hampton Mar 16 '19 at 00:28
  • @MichaelHampton I am entertaining the idea of using supervisord based on wanting to experiment with some of the monitoring/dashboard tools built for supervisord: http://supervisord.org/plugins.html but so far this issue is pushing me back towards systemd – codeAndStuff Mar 18 '19 at 12:24

0 Answers0