; Supervisor for shared cPanel hosting (no sudo). Keeps Reverb and the queue
; worker running. Don't start supervisord directly: supervisor.sh exports
; APP_DIR and PHP_BIN, which this file reads.

[supervisord]
logfile=%(ENV_APP_DIR)s/storage/logs/supervisor/supervisord.log
logfile_maxbytes=5MB
logfile_backups=2
pidfile=%(ENV_APP_DIR)s/storage/logs/supervisor/supervisord.pid
childlogdir=%(ENV_APP_DIR)s/storage/logs/supervisor

[unix_http_server]
; In $HOME, not the app dir: socket paths are capped at ~107 characters.
file=%(ENV_HOME)s/.supervisor-resto.sock
chmod=0700

[supervisorctl]
serverurl=unix://%(ENV_HOME)s/.supervisor-resto.sock

[rpcinterface:supervisor]
supervisor.rpcinterface_factory=supervisor.rpcinterface:make_main_rpcinterface

; Bound to 127.0.0.1 only: browsers and the app reach it through the
; WebSocket proxy rules in public/.htaccess, on port 443.
[program:reverb]
command=%(ENV_PHP_BIN)s %(ENV_APP_DIR)s/artisan reverb:start --host=127.0.0.1 --port=8080
directory=%(ENV_APP_DIR)s
autostart=true
autorestart=true
startsecs=3
stopwaitsecs=10
stopasgroup=true
killasgroup=true
redirect_stderr=true
stdout_logfile=%(ENV_APP_DIR)s/storage/logs/supervisor/reverb.log
stdout_logfile_maxbytes=5MB
stdout_logfile_backups=2

; Sends the queued notifications (FCM pushes). --max-time makes it exit every
; hour so supervisor restarts it fresh and code deploys get picked up.
[program:queue]
command=%(ENV_PHP_BIN)s %(ENV_APP_DIR)s/artisan queue:work --sleep=3 --tries=3 --max-time=3600
directory=%(ENV_APP_DIR)s
autostart=true
autorestart=true
startsecs=3
stopwaitsecs=60
stopasgroup=true
killasgroup=true
redirect_stderr=true
stdout_logfile=%(ENV_APP_DIR)s/storage/logs/supervisor/queue.log
stdout_logfile_maxbytes=5MB
stdout_logfile_backups=2
