; ============================================================================
; Supervisor configuration template for Laravel Horizon
; ============================================================================
; This is a TEMPLATE. The setup-horizon.sh script will replace placeholders
; with actual values derived from your .env file.
;
; Placeholders:
;   {{APP_NAME_SLUG}}  - Derived from APP_NAME in .env (lowercase, dashes)
;   {{DEPLOY_PATH}}    - Auto-detected from current working directory
;   {{PHP_BIN}}        - Auto-detected PHP binary path
;   {{RUN_USER}}       - Auto-detected app owner or web server user
;
; Manual installation (if not using setup-horizon.sh):
;   1. Copy to /etc/supervisor/conf.d/ or /etc/supervisord.d/
;   2. Replace placeholders manually
;   3. Run: sudo supervisorctl reread && sudo supervisorctl update
;
; Horizon Configuration Notes:
; ============================
; Horizon manages all queue workers internally, so you only need ONE supervisor
; process. Horizon will spawn and manage worker processes for each queue based
; on config/horizon.php settings.
;
; After installation:
;   sudo supervisorctl reread
;   sudo supervisorctl update
;   sudo supervisorctl start {{APP_NAME_SLUG}}-horizon
;
; To restart after deployment:
;   sudo supervisorctl restart {{APP_NAME_SLUG}}-horizon
;
; Monitor queue health:
;   php artisan horizon:status
;   (or visit /horizon in browser)
;
; ============================================================================

[program:{{APP_NAME_SLUG}}-horizon]
process_name=%(program_name)s
command={{PHP_BIN}} {{DEPLOY_PATH}}/artisan horizon
directory={{DEPLOY_PATH}}
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user={{RUN_USER}}
numprocs=1
redirect_stderr=true
stdout_logfile={{DEPLOY_PATH}}/storage/logs/horizon.log
stderr_logfile={{DEPLOY_PATH}}/storage/logs/horizon.error.log
; Grace period for Horizon to finish in-progress jobs before SIGKILL.
; 300s (5 min) is sufficient when all jobs define $timeout <= 240.
stopwaitsecs=300
environment=PATH="/opt/cpanel/ea-php84/root/usr/bin:/usr/local/bin:/usr/bin:/bin"
