[supervisord]
loglevel=debug               ; log level; default info; others: debug,warn,trace
logfile=/tmp/issue-733.log   ; main log file; default $CWD/supervisord.log
pidfile=/tmp/issue-733.pid   ; supervisord pidfile; default supervisord.pid
nodaemon=true                ; start in foreground if true; default false

;
;This command does not exist so the process will enter the FATAL state.
;
[program:nonexistent]
command=%(here)s/nonexistent
startsecs=0
startretries=0
autorestart=false

;
;The one-line eventlistener below will cause supervisord to exit when any process
;enters the FATAL state.  Based on:
;https://github.com/Supervisor/supervisor/issues/733#issuecomment-781254766
;
;Differences from that example:
;  1. $PPID is used instead of a hardcoded PID 1.  Child processes are always forked
;     from supervisord, so their PPID is the PID of supervisord.
;  2. "printf" is used instead of "echo".  The result "OK" must not have a newline
;     or else the protocol will be violated and supervisord will log a warning.
;
[eventlistener:fatalexit]
events=PROCESS_STATE_FATAL
command=sh -c 'while true; do printf "READY\n"; read line; kill -15 $PPID; printf "RESULT 2\n"; printf "OK"; done'
startsecs=0
startretries=0
