Skip to content

Instantly share code, notes, and snippets.

@ReallyLiri
Last active July 3, 2019 10:21
Show Gist options
  • Save ReallyLiri/f833510d350b242ff89b9b76fdf21ea5 to your computer and use it in GitHub Desktop.
Save ReallyLiri/f833510d350b242ff89b9b76fdf21ea5 to your computer and use it in GitHub Desktop.
Make tiangolo/uwsgi-nginx crash on python app failure
FROM tiangolo/uwsgi-nginx:python3.7
# or FROM tiangolo/uwsgi-nginx-flask:python3.7
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY stop-supervisor.sh /etc/supervisor/stop-supervisor.sh
RUN chmod +x /etc/supervisor/stop-supervisor.sh
#!/bin/bash
printf "READY\n";
while read line; do
echo "Processing Event: $line" >&2;
kill -3 $(cat "/var/run/supervisord.pid")
done < /dev/stdin
# copied from https://github.com/tiangolo/uwsgi-nginx-docker/blob/master/python3.7/supervisord.conf
[supervisord]
nodaemon=true
[program:uwsgi]
command=/usr/local/bin/uwsgi --ini /etc/uwsgi/uwsgi.ini
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
startsecs = 0
autorestart=false
[program:nginx]
command=/usr/sbin/nginx
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
# Graceful stop, see http://nginx.org/en/docs/control.html
stopsignal=QUIT
[eventlistener:processes]
command=/etc/supervisor/stop-supervisor.sh
events=PROCESS_STATE_STOPPED, PROCESS_STATE_EXITED, PROCESS_STATE_FATAL
@ReallyLiri
Copy link
Author

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