I am using Elastic Beanstalk to configure my web app.
I've used this configuration (.ebextensions/00_supervisor.config):
files:
/etc/supervisord.conf:
mode: "000755"
owner: root
group: root
content: |
[unix_http_server]
file=/tmp/supervisor.sock ; (the path to the socket file)
[supervisord]
logfile=/var/log/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10 ; (num of main logfile rotation backups;default 10)
loglevel=info ; (log level;default info; others: debug,warn,trace)
pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false ; (start in foreground if true;default false)
minfds=1024 ; (min. avail startup file descriptors;default 1024)
minprocs=200 ; (min. avail process descriptors;default 200)
; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket
[include]
files = /usr/local/etc/*.conf
/usr/local/etc/laravel.conf:
mode: "000755"
owner: root
group: root
content: |
[program:horizon]
process_name=%(program_name)s_%(process_num)02d
command=php /var/app/current/artisan horizon
autostart=true
autorestart=true
user=webapp
numprocs=5
redirect_stderr=false
startsecs = 0
commands:
command block:
command: |
easy_install supervisor
supervisord -c /etc/supervisord.conf
test: test ! -e /tmp/supervisor.sock
container_commands:
restart_supervisord:
command: export $(cat /opt/elasticbeanstalk/deployment/env) && supervisorctl reload
I have set up Supervisor to automatically run Laravel Horizon.
This is the created config file after deployment (/usr/local/etc/laravel.conf):
[program:horizon]
process_name=%(program_name)s_%(process_num)02d
command=php /var/app/current/artisan horizon
autostart=true
autorestart=true
user=root
numprocs=5
redirect_stderr=false
startsecs = 0
When I check if horizon is running, it seems to be fine:
[root@ip-172-31-38-73 html]# supervisorctl status all
horizon:horizon_00 RUNNING pid 5436, uptime 0:00:03
horizon:horizon_01 RUNNING pid 5437, uptime 0:00:00
horizon:horizon_02 RUNNING pid 5426, uptime 0:00:06
horizon:horizon_03 RUNNING pid 5405, uptime 0:00:12
horizon:horizon_04 RUNNING pid 5409, uptime 0:00:09
However, checking the supervisor log inside: /var/log/supervisord.log
I can see:
2021-03-26 15:04:41,165 INFO success: horizon_00 entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
2021-03-26 15:04:41,175 INFO exited: horizon_01 (exit status 1; not expected)
2021-03-26 15:04:41,180 INFO spawned: 'horizon_01' with pid 19926
2021-03-26 15:04:41,189 INFO success: horizon_01 entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
2021-03-26 15:04:41,195 INFO exited: horizon_02 (exit status 1; not expected)
2021-03-26 15:04:41,207 INFO spawned: 'horizon_02' with pid 19927
2021-03-26 15:04:41,217 INFO success: horizon_02 entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
2021-03-26 15:04:41,227 INFO exited: horizon_03 (exit status 1; not expected)
2021-03-26 15:04:41,231 INFO spawned: 'horizon_03' with pid 19928
2021-03-26 15:04:41,249 INFO success: horizon_03 entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
2021-03-26 15:04:41,254 INFO exited: horizon_04 (exit status 1; not expected)
2021-03-26 15:04:41,259 INFO spawned: 'horizon_04' with pid 19929
2021-03-26 15:04:41,281 INFO success: horizon_04 entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
I'm not sure what the (exit status 1; not expected) lines mean, but doesn't seem right?
Anyway, when I log in to horizon dashboard and check the status, it says "Inactive".
When I check manually:
[root@ip-172-31-38-73 html]# php artisan horizon:status
Horizon is inactive.
I can start it when I manually type: php artisan horizon
I also tried to follow the steps from official Laravel Horizon page (https://laravel.com/docs/8.x/horizon), but this step fails:
[root@ip-172-31-10-36 html]# supervisorctl start horizon
horizon: ERROR (no such process)
What am I doing wrong? Why doesn't horizon start automatically via supervisor?