gunicorn:无法连接到gunicorn.sock

Ric*_*ard 7 sockets django gunicorn

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

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

gunicorn myapp.wsgi:application --bind xx.xx.xx.xx:8001
Run Code Online (Sandbox Code Playgroud)

但现在我想通过Unix套接字运行它:

gunicorn myapp.wsgi:application --bind=unix$/webapps/myapp/run/gunicorn.sock
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

[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
Run Code Online (Sandbox Code Playgroud)

如果我这样做,ls -al /webapps/myapp/run我看到套接字文件确实存在,虽然它是空的:

srwxrwxrwx 1 opuser webapps 0 Aug 23 07:22 /webapps/myapp/run/gunicorn.sock
Run Code Online (Sandbox Code Playgroud)

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

我最终想以gunicorn用户身份运行opuser,我已尝试附加--user opuser --group webapps到gunicorn命令,但仍然得到相同的错误.

hen*_*oem 5

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

gunicorn myapp.wsgi:application --bind=unix:/webapps/myapp/run/gunicorn.sock
Run Code Online (Sandbox Code Playgroud)