Elastic Beanstalk - 主管 - Laravel Horizo​​n - 不自动启动

问题描述

我正在使用 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

但是,检查里面的supervisor日志:/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,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,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,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/horizon) 中的步骤进行操作,但是这一步失败了:

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

我做错了什么?为什么地平线不能通过主管自动启动?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)