django - gunicorn:无法连接到 gunicorn.sock

标签 django sockets gunicorn

我正在使用 Django 1.8,我想用 gunicorn 运行我的应用程序。

我可以从命令行绑定(bind)到我的 IP 运行它:

gunicorn myapp.wsgi:application --bind xx.xx.xx.xx:8001

但现在我想通过 Unix 套接字运行它:
gunicorn myapp.wsgi:application --bind=unix$/webapps/myapp/run/gunicorn.sock

我收到此错误:
[2015-08-23 07:38:04 +0000] [18598] [INFO] Starting gunicorn 19.3.0
[2015-08-23 07:38:04 +0000] [18598] [ERROR] Retrying in 1 second.
[2015-08-23 07:38:05 +0000] [18598] [ERROR] Retrying in 1 second.
[2015-08-23 07:38:06 +0000] [18598] [ERROR] Retrying in 1 second.
[2015-08-23 07:38:07 +0000] [18598] [ERROR] Retrying in 1 second.
[2015-08-23 07:38:08 +0000] [18598] [ERROR] Retrying in 1 second.
[2015-08-23 07:38:09 +0000] [18598] [ERROR] Can't connect to $/webapps/myapp/run/gunicorn.sock

如果我这样做 ls -al /webapps/myapp/run我看到套接字文件确实存在,尽管它是空的:
srwxrwxrwx 1 opuser webapps 0 Aug 23 07:22 /webapps/myapp/run/gunicorn.sock

我怎样才能解决这个问题?

我最终想运行 gunicorn作为用户opuser , 我试过追加 --user opuser --group webapps到 gunicorn 命令,但仍然得到相同的错误。

最佳答案

根据文档( http://gunicorn-docs.readthedocs.org/en/latest/run.html ),您应该使用: unix:$(PATH) ,这意味着您的命令应为:

gunicorn myapp.wsgi:application --bind=unix:/webapps/myapp/run/gunicorn.sock

关于django - gunicorn:无法连接到 gunicorn.sock,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32166270/

相关文章:

python - 缺少子资源完整性保护

java - 编写点对点聊天系统时遇到问题

Django Gunicorn Nginx "connection reset by peer while reading response header"

node.js - Sails 没有方法 'subscribeToFirehose'

Java套接字/序列化,对象不会更新

python - gunicorn_django 错误 "cannot find myproject.settings in your PYTHONPATH"

django - 在同一个 python 进程上运行多个站点

django - CSS 文件的 404(未找到)

python - 如何清理在 django-nose 测试函数中所做的数据库更改?

python - 如何通过多个关键字从数据库中过滤DRF中的数据?