【问题标题】:Laravel websockets causes python socket errorLaravel websockets导致python套接字错误
【发布时间】:2020-05-09 16:23:09
【问题描述】:

我使用 amazon ec2 在 ubuntu 18.04 中安装了一个项目。我可以从我的项目目录手动测试由websockets:serve 命令运行的websocket 服务器。现在我想运行 websockets,docs 说我需要安装supervisor,这就是我所做的。我在/etc/supervisor/conf.d/websockets.conf 中创建了一个配置文件,它有这个配置

[program:websockets]
command=usr/bin/php cd /var/www/html/Inventory/artisan websockets:serve
numprocs=1
autostart=true
autorestart=true
user=laravel-echo

当我做supervisorctl update时,我得到的是

error: <class 'socket.error'>, [Errno 2] No such file or directory: file: /usr/lib/python2.7/socket.py line: 228

当我也做sudo supervisorctl status 时,我得到的是

unix:///var/run/supervisor.sock no such file

我的/etc 目录中没有supervisor.confsupervisor.conf 文件在/etc/supervisor/supervisor.conf 中,就像其他人遇到的一样。

我需要创建一个supervisor.sock 文件吗?还是主管会自动创建它?另外,如果我不能解决这个问题,我的第二个选择是通过 cronjob 运行 websockets。这是正确的做法吗?

无论如何,如果你们对此有所了解,请提供帮助。谢谢..

【问题讨论】:

标签: php laravel ubuntu websocket supervisord


【解决方案1】:

只需从命令中删除“cd”

[program:websockets]
command=/usr/bin/php /var/www/html/Inventory/artisan websockets:serve
numprocs=1
autostart=true
autorestart=true
user=laravel-echo

你可以找到一些参考here

【讨论】:

【解决方案2】:
[program:laravel-websocket]
command=/path/to/your/php /var/www/vhosts/path/to/yout/artisan websockets:serve
autostart=true
autorestart=true
user=your_user
stderr_logfile=/var/log/supervisor-laravel.websocket.err.log
stdout_logfile=/var/log/supervisor-laravel.websocket.out.log

永远不要以 root 身份运行

绝对路径,当然要遵循 supervisord 配置指南

检查错误日志

对配置的端口进行 netcat/port 扫描,以确保您不会错过代理/防火墙规则

参考:https://github.com/beyondcode/laravel-websockets/issues/304#issuecomment-590809667

【讨论】:

  • 我的 websockets:serve 目录是否错误?我在正确的目录中指出了它
  • 可以重启服务器吗?
  • 我可以运行 websockets。这只是主管问题。
  • 如果你重新启动它将启动supervisor并从supervisor运行websockets,然后你检查日志
  • 很高兴你修好了 :)
【解决方案3】:

我的临时解决方案,我只是用cron每年运行一次websockets:serve

51 16 9 5 * cd /var/www/html/Inventory/ && php artisan websockets:serve >> /dev/null 2>&1 >> /var/www/html/Inventory/websockets.log

【讨论】:

    猜你喜欢
    • 2011-03-19
    • 2021-02-28
    • 2016-03-04
    • 1970-01-01
    • 1970-01-01
    • 2011-07-19
    • 1970-01-01
    • 2018-10-30
    • 2013-09-12
    相关资源
    最近更新 更多