主管没有这样的文件 socket.py
Supervisor no such file socket.py
我正在尝试为 laravel 设置一个队列侦听器,但似乎无法让主管正常工作。当我 运行 supervisorctl reload
:
时出现以下错误
error: <class 'socket.error'>, [Errno 2] No such file or directory: file: /usr/lib/python2.7/socket.py line: 228
文件确实存在。如果尝试 运行 sudo supervisorctl
我明白了
unix:///var/run/supervisor.sock no such file
.
我试过重新安装 supervisor 也没有用。不知道在这里做什么。
我是 运行宁 Laravel 宅基地 (Ubuntu 16.04)。
service supervisor status
的结果:
vagrant@homestead:~/Code$ sudo service supervisor status
● supervisor.service - Supervisor process control system for UNIX
Loaded: loaded (/lib/systemd/system/supervisor.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Thu 2016-12-22 11:06:21 EST; 41s ago
Docs: http://supervisord.org
Process: 23154 ExecStop=/usr/bin/supervisorctl $OPTIONS shutdown (code=exited, status=0/SUCCESS)
Process: 23149 ExecStart=/usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf (code=exited, status=2)
Main PID: 23149 (code=exited, status=2)
我最终只是完全删除了 supervisor,重新安装并重写了我的配置文件。我一定是在这个过程中做错了什么,没能抓住它。
你可以试试
sudo touch /var/run/supervisor.sock
sudo chmod 777 /var/run/supervisor.sock
在 Ubuntu 18.04 中带有分发包
您可能犯了和我一样的错误,在我的服务经理 (systemd) 使用配置文件 /etc/supervisor/supervisord.conf
时创建了配置文件 /etc/supervisord.conf
解决方案
删除创建的配置文件
sudo rm /etc/supervisord.conf
将其移动到正确的位置
sudo mv /etc/supervisord.conf /etc/supervisor/supervisord.conf
现在你可以运行sudo supervisorctl
为什么?
当你 运行 supervisorctl
它首先搜索位于 /etc/supervisord.conf
的配置文件,如果它不存在,它将搜索包的默认文件 /etc/supervisor/supervisord.conf
这是 systemd 实际上 运行s.
Systemd 总是使用文件 /etc/supervisor/supervisord.conf
而不管其他文件是否存在。
您可以通过 运行ning sudo systemctl status supervisor
检查哪个文件正在使用 systemd
您可以在最后一行看到配置文件被硬编码的命令
当你在主管目录时,你应该运行 sudo service supervisor start
。
对我有用。
检查 supervisord.conf 文件。
查找以下内容:
[unix_http_server]
file=/path/to/supervisor.sock/file ; (the path to the socket file)
chmod=0700 ; sockef file mode(default 0700)
转到上述路径并检查文件是否存在。
如果存在,则尝试 re-installing supervisor。
如果没有,则使用命令行或文件资源管理器 GUI 搜索 supervisor.sock 文件。
使用 cp 命令或 GUI 将上述步骤中找到的文件复制到 [unix_http_server] 中指定的位置。
对我来说,supervisor.sock 存在于 /运行 文件夹中。
2020 UPDATE
Try running sudo service supervisor start
in your terminal before using the below solution. I found out that the issue sometimes occurs when supervisor
is not running, nothing complicated.
我正在使用 Ubuntu 18.04
。我遇到了同样的问题,重新安装 supervisor 并没有解决我的问题。
我最终完全删除了 conf.d 目录并使用新配置重新创建它。 确保在尝试此操作之前备份您的配置:
sudo rm -rf /etc/supervisor/conf.d/
sudo mkdir /etc/supervisor/conf.d
sudo nano /etc/supervisor/conf.d/my-file.conf
- 将配置复制并粘贴到新文件中。
sudo supervisorctl reread
又开始工作了。
我 运行 进入这个问题是因为我们使用 supervisorctl 来管理 gunicorn。我的问题的根源与主管无关(它处理其他进程很好)或 python sock.py 文件(文件在那里,权限是正确的),而是 gunicorn 配置文件 /etc/supervisor/conf.d/gunicorn.conf
。此配置文件由带有环境变量的源代码控制模板管理,当我们在服务器上更新模板时,模板变量从未被实际数据替换。因此,例如 gunicorn.conf 文件中的某些内容读取 user={{ user }}
而不是 user=gunicorn
。当主管在 运行 supervisorctl start gunicorn
时尝试解析此配置时,它会因此套接字错误而崩溃。修复 gunicorn.conf 文件解决了主管问题。
您可以尝试删除所有与supervisor相关的文件夹并完全卸载supervisor。
sudo rm -rf /var/log/supervisor/supervisord.log
sudo rm -rf /etc/supervisor/conf.d/
执行此操作后,通过
重新安装主管
sudo apt install supervisor
现在,您可以 运行 正确了。检查
sudo systemctl status supervisor
我遇到了一个非常相似的问题 (Ubuntu 18.04) 并搜索了类似的主题但无济于事,所以在这里回答一些更全面的答案。
缺少 sock 文件或套接字错误仅表明主管未 运行ning。如果简单的重启不起作用,则要么是 1. 未安装,要么 2. 无法启动。在我的例子中,没有任何东西被记录到 supervisor.log 文件让我知道它为什么失败,直到我 运行 以下命令(-n 到 运行 在前台)才发现我错过了一个已删除的项目的剩余配置文件。
/usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf
一旦我删除了 conf.d 文件夹中的 bad/leftover 文件并使用 sudo service supervisor start
启动它,一切正常。
以下是您可以采取的一些综合步骤。
- supervisor安装了吗?
dpkg -l | grep supervisor
如果没有重新安装sudo apt install supervisor
- supervisor 的所有实例都停止了吗?
systemctl stop supervisor
可以找到挥之不去的主管进程 ps aux | grep supervisor
然后 kill -9 PID
。
- supervisor.conf 的位置是否正确
/etc/supervisor/supervisor.conf
并且没有语法错误?从包中重新安装将更正此问题。
- 将 conf.d/ 中的特定文件暂时移出该文件夹,尝试在没有其他配置文件的情况下启动。如果它启动正确
sudo service supervisor start
您的项目 .conf 文件中可能存在错误。
- 使用
sudo service supervisor status
检查状态。
- 将您的 .conf 文件一一移回 conf.d/ 并重新启动
sudo service supervisor restart
。务必检查与 sudo service supervisor status
之间。如果失败,您知道哪个 .conf 文件有问题并可以寻求具体帮助。
- 检查所有内容是否为 运行
supervisorctl status
如果不是 supervisorctl start all
.
我用官方文档试了一次,遇到了python file not found an error, code=exited, status=2
,还是一样。
我为我的 laravel 应用程序尝试了很多解决方案。
但最后,我尝试了我的解决方案。
这是代码示例:
[program:dev-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/html/example.com/artisan queue:work --sleep=3 --tries=3
autostart=true
autorestart=true
user=ubuntu
numprocs=8
redirect_stderr=true
stdout_logfile=/var/www/html/example.com/storage/logs/laravel.log
stopwaitsecs=3600
参考:https://laravel.com/docs/7.x/queues#supervisor-configuration
如果通过 运行 sudo service supervisor status
你得到以下结果:
ExecStart=/usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf (code=exited, status=2)
尝试运行/usr/bin/supervisord
,它会给你明确的信息,告诉你错误在哪里。
None 的关于答案帮助了我。
问题是我没有关注 supervisor documentation。
我没有做的一个步骤是 运行 echo_supervisord_conf
创建配置文件的命令。
我为做的步骤 Ubuntu 18.04:
正在安装主管(没有 pip):
sudo apt-get install supervisor
echo_supervisord_conf > /etc/supervisord.conf
(具有 root 访问权限:首先 运行 sudo -i
然后 echo_supervisord_conf > /etc/supervisord.conf
)
- 将 python 依赖更改为 python2
(Depends: python-pkg-resources, init-system-helpers (>= 1.18~), python-meld3, python:any (<< 2.8), python:any (>= 2.7.5-5~)
在这些文件中:/usr/bin/supervisord
| /usr/bin/supervisorctl
| /usr/bin/echo_supervisord_conf
。
只需将第一行从 #!/usr/bin/python
更改为 #!/usr/bin/python2
- 运行
supervisord
- 完成
希望得到帮助!
Source of answer : http://supervisord.org/installing.html
- 运行 命令:
echo_supervisord_conf
- 一旦您看到文件回显到您的终端,请重新调用命令
echo_supervisord_conf > /etc/supervisord.conf
。如果您没有 root 访问权限,这将不起作用。
- 如果您没有 root 访问权限,或者您不想将
supervisord.conf
文件放在 /etc/supervisord.conf
中,您可以将它放在当前目录中 (echo_supervisord_conf > supervisord.conf
)并使用 -c
标志启动 supervisord 以指定配置文件位置。
错误现在应该已经解决了。
我在 CentOS 上执行了以下操作来解决问题 Linux 7
sudo systemctl status supervisord.service
通过上面的命令,我发现程序处于活动状态
sudo systemctl start supervisord.service
现在我使用上面的命令启动服务,现在一切正常
在 Centos 7 上我使用以下...
supervisord -c /path/to/supervisord.conf
其次是...
supervisorctl -c /path/to/supervisord.conf
这消除了“找不到 .sock 文件”错误。现在您必须使用...
终止旧进程
ps aux|grep gunicorn
使用...终止违规进程
kill <pid>
然后再...
supervisorctl -c /path/to/supervisord.conf
如果您的配置正确,Supervisor 现在应该 运行 正确。
我正在尝试为 laravel 设置一个队列侦听器,但似乎无法让主管正常工作。当我 运行 supervisorctl reload
:
error: <class 'socket.error'>, [Errno 2] No such file or directory: file: /usr/lib/python2.7/socket.py line: 228
文件确实存在。如果尝试 运行 sudo supervisorctl
我明白了
unix:///var/run/supervisor.sock no such file
.
我试过重新安装 supervisor 也没有用。不知道在这里做什么。
我是 运行宁 Laravel 宅基地 (Ubuntu 16.04)。
service supervisor status
的结果:
vagrant@homestead:~/Code$ sudo service supervisor status
● supervisor.service - Supervisor process control system for UNIX
Loaded: loaded (/lib/systemd/system/supervisor.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Thu 2016-12-22 11:06:21 EST; 41s ago
Docs: http://supervisord.org
Process: 23154 ExecStop=/usr/bin/supervisorctl $OPTIONS shutdown (code=exited, status=0/SUCCESS)
Process: 23149 ExecStart=/usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf (code=exited, status=2)
Main PID: 23149 (code=exited, status=2)
我最终只是完全删除了 supervisor,重新安装并重写了我的配置文件。我一定是在这个过程中做错了什么,没能抓住它。
你可以试试
sudo touch /var/run/supervisor.sock
sudo chmod 777 /var/run/supervisor.sock
在 Ubuntu 18.04 中带有分发包
您可能犯了和我一样的错误,在我的服务经理 (systemd) 使用配置文件 /etc/supervisor/supervisord.conf
时创建了配置文件 /etc/supervisord.conf
解决方案
删除创建的配置文件
sudo rm /etc/supervisord.conf
将其移动到正确的位置
sudo mv /etc/supervisord.conf /etc/supervisor/supervisord.conf
现在你可以运行sudo supervisorctl
为什么?
当你 运行 supervisorctl
它首先搜索位于 /etc/supervisord.conf
的配置文件,如果它不存在,它将搜索包的默认文件 /etc/supervisor/supervisord.conf
这是 systemd 实际上 运行s.
Systemd 总是使用文件 /etc/supervisor/supervisord.conf
而不管其他文件是否存在。
您可以通过 运行ning sudo systemctl status supervisor
当你在主管目录时,你应该运行 sudo service supervisor start
。
对我有用。
检查 supervisord.conf 文件。
查找以下内容:
[unix_http_server]
file=/path/to/supervisor.sock/file ; (the path to the socket file)
chmod=0700 ; sockef file mode(default 0700)
转到上述路径并检查文件是否存在。
如果存在,则尝试 re-installing supervisor。
如果没有,则使用命令行或文件资源管理器 GUI 搜索 supervisor.sock 文件。
使用 cp 命令或 GUI 将上述步骤中找到的文件复制到 [unix_http_server] 中指定的位置。
对我来说,supervisor.sock 存在于 /运行 文件夹中。
2020 UPDATE
Try running
sudo service supervisor start
in your terminal before using the below solution. I found out that the issue sometimes occurs whensupervisor
is not running, nothing complicated.
我正在使用 Ubuntu 18.04
。我遇到了同样的问题,重新安装 supervisor 并没有解决我的问题。
我最终完全删除了 conf.d 目录并使用新配置重新创建它。 确保在尝试此操作之前备份您的配置:
sudo rm -rf /etc/supervisor/conf.d/
sudo mkdir /etc/supervisor/conf.d
sudo nano /etc/supervisor/conf.d/my-file.conf
- 将配置复制并粘贴到新文件中。
sudo supervisorctl reread
又开始工作了。
我 运行 进入这个问题是因为我们使用 supervisorctl 来管理 gunicorn。我的问题的根源与主管无关(它处理其他进程很好)或 python sock.py 文件(文件在那里,权限是正确的),而是 gunicorn 配置文件 /etc/supervisor/conf.d/gunicorn.conf
。此配置文件由带有环境变量的源代码控制模板管理,当我们在服务器上更新模板时,模板变量从未被实际数据替换。因此,例如 gunicorn.conf 文件中的某些内容读取 user={{ user }}
而不是 user=gunicorn
。当主管在 运行 supervisorctl start gunicorn
时尝试解析此配置时,它会因此套接字错误而崩溃。修复 gunicorn.conf 文件解决了主管问题。
您可以尝试删除所有与supervisor相关的文件夹并完全卸载supervisor。
sudo rm -rf /var/log/supervisor/supervisord.log
sudo rm -rf /etc/supervisor/conf.d/
执行此操作后,通过
重新安装主管sudo apt install supervisor
现在,您可以 运行 正确了。检查
sudo systemctl status supervisor
我遇到了一个非常相似的问题 (Ubuntu 18.04) 并搜索了类似的主题但无济于事,所以在这里回答一些更全面的答案。
缺少 sock 文件或套接字错误仅表明主管未 运行ning。如果简单的重启不起作用,则要么是 1. 未安装,要么 2. 无法启动。在我的例子中,没有任何东西被记录到 supervisor.log 文件让我知道它为什么失败,直到我 运行 以下命令(-n 到 运行 在前台)才发现我错过了一个已删除的项目的剩余配置文件。
/usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf
一旦我删除了 conf.d 文件夹中的 bad/leftover 文件并使用 sudo service supervisor start
启动它,一切正常。
以下是您可以采取的一些综合步骤。
- supervisor安装了吗?
dpkg -l | grep supervisor
如果没有重新安装sudo apt install supervisor
- supervisor 的所有实例都停止了吗?
systemctl stop supervisor
可以找到挥之不去的主管进程ps aux | grep supervisor
然后kill -9 PID
。 - supervisor.conf 的位置是否正确
/etc/supervisor/supervisor.conf
并且没有语法错误?从包中重新安装将更正此问题。 - 将 conf.d/ 中的特定文件暂时移出该文件夹,尝试在没有其他配置文件的情况下启动。如果它启动正确
sudo service supervisor start
您的项目 .conf 文件中可能存在错误。 - 使用
sudo service supervisor status
检查状态。 - 将您的 .conf 文件一一移回 conf.d/ 并重新启动
sudo service supervisor restart
。务必检查与sudo service supervisor status
之间。如果失败,您知道哪个 .conf 文件有问题并可以寻求具体帮助。 - 检查所有内容是否为 运行
supervisorctl status
如果不是supervisorctl start all
.
我用官方文档试了一次,遇到了python file not found an error, code=exited, status=2
,还是一样。
我为我的 laravel 应用程序尝试了很多解决方案。
但最后,我尝试了我的解决方案。
这是代码示例:
[program:dev-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/html/example.com/artisan queue:work --sleep=3 --tries=3
autostart=true
autorestart=true
user=ubuntu
numprocs=8
redirect_stderr=true
stdout_logfile=/var/www/html/example.com/storage/logs/laravel.log
stopwaitsecs=3600
参考:https://laravel.com/docs/7.x/queues#supervisor-configuration
如果通过 运行 sudo service supervisor status
你得到以下结果:
ExecStart=/usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf (code=exited, status=2)
尝试运行/usr/bin/supervisord
,它会给你明确的信息,告诉你错误在哪里。
None 的关于答案帮助了我。
问题是我没有关注 supervisor documentation。
我没有做的一个步骤是 运行 echo_supervisord_conf
创建配置文件的命令。
我为做的步骤 Ubuntu 18.04:
正在安装主管(没有 pip):
sudo apt-get install supervisor
echo_supervisord_conf > /etc/supervisord.conf
(具有 root 访问权限:首先 运行sudo -i
然后echo_supervisord_conf > /etc/supervisord.conf
)- 将 python 依赖更改为 python2
(
Depends: python-pkg-resources, init-system-helpers (>= 1.18~), python-meld3, python:any (<< 2.8), python:any (>= 2.7.5-5~)
在这些文件中:/usr/bin/supervisord
| /usr/bin/supervisorctl
| /usr/bin/echo_supervisord_conf
。
只需将第一行从 #!/usr/bin/python
更改为 #!/usr/bin/python2
- 运行
supervisord
- 完成
希望得到帮助!
Source of answer : http://supervisord.org/installing.html
- 运行 命令:
echo_supervisord_conf
- 一旦您看到文件回显到您的终端,请重新调用命令
echo_supervisord_conf > /etc/supervisord.conf
。如果您没有 root 访问权限,这将不起作用。 - 如果您没有 root 访问权限,或者您不想将
supervisord.conf
文件放在/etc/supervisord.conf
中,您可以将它放在当前目录中 (echo_supervisord_conf > supervisord.conf
)并使用-c
标志启动 supervisord 以指定配置文件位置。
错误现在应该已经解决了。
我在 CentOS 上执行了以下操作来解决问题 Linux 7
sudo systemctl status supervisord.service
通过上面的命令,我发现程序处于活动状态
sudo systemctl start supervisord.service
现在我使用上面的命令启动服务,现在一切正常
在 Centos 7 上我使用以下...
supervisord -c /path/to/supervisord.conf
其次是...
supervisorctl -c /path/to/supervisord.conf
这消除了“找不到 .sock 文件”错误。现在您必须使用...
终止旧进程ps aux|grep gunicorn
使用...终止违规进程
kill <pid>
然后再...
supervisorctl -c /path/to/supervisord.conf
如果您的配置正确,Supervisor 现在应该 运行 正确。