我正在使用 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/