The trick is to only register the listener for events that indicate failure, namely
- PROCESS_STATE_STOPPED
- PROCESS_STATE_EXITED
- PROCESS_STATE_FATAL
Once they do, we should send a SIGQUIT
to Supervisor.
#!/bin/bash | |
printf "READY\n"; | |
while read line; do | |
echo "Processing Event: $line" >&2; | |
kill -3 $(cat "/var/run/supervisord.pid") | |
done < /dev/stdin |
[supervisord] | |
nodaemon=true | |
loglevel=debug | |
logfile=/var/log/supervisor/supervisord.log | |
pidfile=/var/run/supervisord.pid | |
childlogdir=/var/log/supervisor | |
[program:nginx] | |
command=nginx -g "daemon off;" | |
redirect_stderr=true | |
[program:php-fpm] | |
command=php-fpm | |
redirect_stderr=true | |
[eventlistener:processes] | |
command=stop-supervisor.sh | |
events=PROCESS_STATE_STOPPED, PROCESS_STATE_EXITED, PROCESS_STATE_FATAL |