无法与主管一起启动laravel-echo-server

问题描述 投票:0回答:1

我已经参考了人们在其他职位上提出的所有其他建议,但没有任何效果。

相关文件的路径

我的项目的根目录是/var/www/html,这是我的.envlaravel-echo-server.json

我已在全局安装laravel-echo-server。我可以使用laravel-echo-server start --dir=/path/to/project/root

从a成功运行它

当我运行which laravel-echo-server时,它显示其路径为~/.nvm/versions/node/v13.5.0/bin/laravel-echo-server

同样,节点的路径为~/.nvm/versions/node/v13.5.0/bin/node

我的主管工作人员的conf文件位于/etc/supervisor/conf.d/laravel-echo-server.conf

Supervisor成功地运行了其他工作程序,例如Horizo​​n,因此,Supervisor配置没有问题。

Conf文件

[program:laravel-echo-server]
process_name=%(program_name)s_%(process_num)02d
command=laravel-echo-server start --dir=/var/www/html
autostart=true
numprocs=1
user=root
autorestart=true
stdout_logfile=/var/log/workers/laravel-echo-server.log

我也在命令行中尝试了以下变体:

command=/usr/bin/laravel-echo-server start --dir=/var/www/html
command=~/.nvm/versions/node/v13.5.0/bin/laravel-echo-server --dir=/var/www/html

所有这些尝试和变化都返回ERROR (no such file)

[我还尝试制作laravel-echo-server.json的重复副本以放置在/usr/bin/etc/supervisor/conf.d之类的位置,但这没有帮助。

我还尝试过将用户从root更改为ec2-user(这是我的用户名,我可以使用该用户名从命令行成功初始化laravel-echo-server)。

我也尝试添加另一行:directory=/var/www/html,但这无济于事。

Shell可执行的尝试

我试图制作一个主管可以调用的shell可执行文件。这是文件:

#!/bin/bash
exec laravel-echo-server start --dir=../../../var/www/html

我像这样用主管叫可执行文件:

command=bash -c laravel-echo-server.sh

但是它返回了ERROR (spawn error)

附加信息

supervisord.conf

[inet_http_server]
port=*:9001

[unix_http_server]
file=/var/run/supervisor.sock   ; (the path to the socket file)
chmod=0700                       ; sockef file mode (default 0700)

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisord]
;http_port=/var/tmp/supervisor.sock ; (default is to run a UNIX domain socket server)
;http_port=127.0.0.1:9001  ; (alternately, ip_address:port specifies AF_INET)
;sockchmod=0700              ; AF_UNIX socketmode (AF_INET ignore, default 0700)
;sockchown=nobody.nogroup     ; AF_UNIX socket uid.gid owner (AF_INET ignores)
;umask=022                   ; (process file creation umask;default 022)
logfile=/var/log/supervisor/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               ; (logging level;default info; others: debug,warn)
pidfile=/var/run/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)

;nocleanup=true              ; (don't clean up tempfiles at start;default false)
;http_username=user          ; (default is no username (open system))
;http_password=123           ; (default is no password (open system))
;childlogdir=/tmp            ; ('AUTO' child log dir, default $TEMP)
;user=chrism                 ; (default is current user, required if root)
;directory=/tmp              ; (default is not to cd during start)
;environment=KEY=value       ; (key value pairs to add to environment)

[supervisorctl]
serverurl=unix:///var/run/supervisor.sock
;serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket
;username=chris              ; should be same as http_username if set
;password=123                ; should be same as http_password if set
;prompt=mysupervisor         ; cmd line prompt (default "supervisor")

[include]
files = /etc/supervisor/conf.d/*.conf

laravel-echo-server.json

{
    "authHost": http://mywebsite.com,
    "authEndpoint": "/broadcasting/auth",
    "clients": [],
    "database": "redis",
    "databaseConfig": {
        "redis": {[my redis credentials]},
        "sqlite": {
            "databasePath": "/database/laravel-echo-server.sqlite"
        }
    },
    "devMode": true,
    "host": null,
    "port": "6001",
    "protocol": "http",
    "socketio": {},
    "sslCertPath": "",
    "sslKeyPath": "",
    "sslCertChainPath": "",
    "sslPassphrase": "",
    "subscribers": {
        "http": true,
        "redis": true
    },
    "apiOriginAllow": {
        "allowCors": false,
        "allowOrigin": "",
        "allowMethods": "",
        "allowHeaders": ""
    }
}

更新

现在我已经尝试:

command=/home/ec2-user/.nvm/versions/node/v13.5.0/bin/laravel-echo-server start --dir=/var/www/html

根据帖子评论中的建议。但是,这返回ERROR (spawn error)

当我检查supervisord.log时,它显示以下内容:

2019-12-31 07:27:05,869 INFO exited: laravel-echo-server_00 (exit status 127; not expected)

退出状态代码127显然意味着“未找到命令”。

linux laravel socket.io supervisord laravel-echo
1个回答
0
投票

因此,在放弃使用作曲器运行它之后,最容易使用pm2运行它。

这是我的.ebextensions命令:

sudo yum install -y gcc-c++ make
curl -sL https://rpm.nodesource.com/setup_13.x | sudo -E bash -
sudo yum install -y nodejs
npm config set scripts-prepend-node-path true
npm install -g laravel-echo-server
npm install -g pm2@latest
pm2 start laravel-echo-server-pm2.json

还有我的pm2 json:

{
  "name": "laravel-echo-server",
  "script": "laravel-echo-server",
  "args": "start"
}

我还在.ebextensions中添加了一些其他命令,这些命令使我可以修改.env文件。所做的更改将覆盖写入laravel-echo-server.json的值。这样,我不必每次从dev切换到prod时都更改它们:

echo "LARAVEL_ECHO_SERVER_REDIS_HOST=production-redis-host.com" >> .env
echo "LARAVEL_ECHO_SERVER_REDIS_PORT=6379" >> .env
echo "LARAVEL_ECHO_SERVER_DEBUG=false" >> .env
© www.soinside.com 2019 - 2024. All rights reserved.