0

我正在使用 Elastic Beanstalk 来配置我的 Web 应用程序。

我使用了这个配置(.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

我已经设置了 Supervisor 来自动运行 Laravel Horizo​​n。

这是部署后创建的配置文件(/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

当我检查地平线是否正在运行时,它似乎很好:

[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

但是,检查内部的主管日志:/var/log/supervisord.log

我可以看到:

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)

我不确定 (exit status 1; not expected) 行是什么意思,但似乎不对?

无论如何,当我登录到地平线仪表板并检查状态时,它会显示“非活动”。

当我手动检查时:

[root@ip-172-31-38-73 html]# php artisan horizon:status
Horizon is inactive.

我可以在手动输入时启动它:php artisan horizo​​n

我也尝试按照官方 Laravel Horizo​​n 页面(https://laravel.com/docs/8.x/horizo ​​n )中的步骤进行操作,但此步骤失败:

[root@ip-172-31-10-36 html]# supervisorctl start horizon
horizon: ERROR (no such process)

我究竟做错了什么?为什么 Horizo​​n 不通过主管自动启动?

4

0 回答 0