; ========== Laravel Scheduler ==========
[program:scheduler]
directory=/var/www/html
command=php artisan schedule:work
user=www-data
numprocs=1
autostart=true
autorestart=true
startretries=3
stdout_logfile=/var/www/html/storage/logs/supervisor/scheduler/scheduler.out.log
stdout_logfile_maxbytes=10MB
stdout_logfile_backups=3
stderr_logfile=/var/www/html/storage/logs/supervisor/scheduler/scheduler.err.log
stderr_logfile_maxbytes=10MB
stderr_logfile_backups=3
priority=20
stopasgroup=true
killasgroup=true

; ========== Queue Workers ==========
; 高優先
[program:worker-high]
directory=/var/www/html
command=php artisan queue:work --queue=high,training --sleep=2 --tries=5 --timeout=600 --backoff=10
user=www-data
numprocs=1
process_name=%(program_name)s_%(process_num)02d
autostart=true
autorestart=true
startretries=3
stopwaitsecs=3600
stdout_logfile=/var/www/html/storage/logs/supervisor/workers/%(program_name)s.out.log
stdout_logfile_maxbytes=50MB
stdout_logfile_backups=5
stderr_logfile=/var/www/html/storage/logs/supervisor/workers/%(program_name)s.err.log
stderr_logfile_maxbytes=50MB
stderr_logfile_backups=5
priority=30
stopasgroup=true
killasgroup=true

; 一般/低優先（default、mail、low）
[program:worker-default]
directory=/var/www/html
command=php artisan queue:work --queue=default,mail,low --sleep=3 --tries=3 --timeout=120 --backoff=5
user=www-data
numprocs=1
process_name=%(program_name)s_%(process_num)02d
autostart=true
autorestart=true
startretries=3
stopwaitsecs=1800
stdout_logfile=/var/www/html/storage/logs/supervisor/workers/%(program_name)s.out.log
stdout_logfile_maxbytes=50MB
stdout_logfile_backups=5
stderr_logfile=/var/www/html/storage/logs/supervisor/workers/%(program_name)s.err.log
stderr_logfile_maxbytes=50MB
stderr_logfile_backups=5
priority=31
stopasgroup=true
killasgroup=true

;把 workers 組成一個 group，方便一次 start/stop
[group:workers]
programs=worker-high,worker-default
priority=30

