gpt4 book ai didi

python - Gunicorn - ValueError : '' is not a socket

转载 作者:行者123 更新时间:2023-12-05 07:10:35 25 4
gpt4 key购买 nike

我在 gunicorn 上运行一个简单的 flask 应用程序,使用 nginx 作为代理服务器。我不断收到此错误,我无法弄清楚原因。

我认为 gunicorn 负责在我指定的路径中创建 sock 文件,对吗?我已附上所需的文件以供引用。

这是我的 python conf 文件 -

bind = 'unix:/home/ubuntu/<app_folder>/<service name>.sock'
worker_class='gevent'
worker_connections=1000
workers=6
preload_app=True
timeout=600

我正在使用 systemctl 服务来启动 gunicorn -

[Unit]
Description=Gunicorn service to serve requests for <service_name>
PartOf=global_wsgi_starter.service
After=global_wsgi_starter.service
[Service]
User=ubuntu
Group=www-data
WorkingDirectory=<path to code>
Environment="PATH=/home/ubuntu/miniconda3/envs/virtual_env/bin"
ExecStart=/home/ubuntu/miniconda3/envs/virtual_env/bin/gunicorn -c <path_to_conf.py> server:app
[Install]
WantedBy=global_wsgi_starter.service

这是 global_wsgi_starter.service -

[Unit]
Description=Starter process for all wsgi processes.
[Service]
# The dummy program will exit
Type=oneshot
# Execute a dummy program
ExecStart=/bin/true
# This service shall be considered active after start
RemainAfterExit=yes
[Install]
# Components of this application should be started at boot time
WantedBy=multi-user.target

最佳答案

有时 sock 文件会因人为错误而损坏。删除path.sock文件,重新生成

rm -rf app.sock
sudo systemctl restart app
sudo systemctl enable app

它会再次生成一个sock文件,然后重启服务器。

关于python - Gunicorn - ValueError : '<path_to_sock.sock>' is not a socket,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61154722/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com