Gunicorn无法连接到Alpine上的袜子文件

有关此主题的问题很多,但没有一个对我有帮助。


我正在尝试将Gunicorn连接到其中,/tmp/gunicorn.sock但我继续前进operation not permitted。我的gunicorn.conf.py样子是:


import multiprocessing


# bind = '127.0.0.1:5000'

bind = 'unix:/tmp/gunicorn.sock'


backlog = 2048

preload_app = True

max_requests = 2048

max_requests_jitter = 128


workers = multiprocessing.cpu_count() * 2 + 1

worker_connections = 1000

timeout = 60

keepalive = 2


errorlog = '-'

loglevel = 'debug'

accesslog = '-'

access_log_format = '%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"'



def when_ready(server):

    open('/tmp/app-initialized', 'w').close()

和我的日志是:


[2018-08-03 02:34:40 +0000] [116] [INFO] Starting gunicorn 19.9.0

[2018-08-03 02:34:40 +0000] [116] [DEBUG] connection to /tmp/gunicorn.sock failed: [Errno 1] Operation not permitted

[2018-08-03 02:34:40 +0000] [116] [ERROR] Retrying in 1 second.

[2018-08-03 02:34:41 +0000] [116] [DEBUG] connection to /tmp/gunicorn.sock failed: [Errno 1] Operation not permitted

[2018-08-03 02:34:41 +0000] [116] [ERROR] Retrying in 1 second.

[2018-08-03 02:34:42 +0000] [116] [DEBUG] connection to /tmp/gunicorn.sock failed: [Errno 1] Operation not permitted

[2018-08-03 02:34:42 +0000] [116] [ERROR] Retrying in 1 second.

[2018-08-03 02:34:43 +0000] [116] [DEBUG] connection to /tmp/gunicorn.sock failed: [Errno 1] Operation not permitted

[2018-08-03 02:34:43 +0000] [116] [ERROR] Retrying in 1 second.

[2018-08-03 02:34:44 +0000] [116] [DEBUG] connection to /tmp/gunicorn.sock failed: [Errno 1] Operation not permitted

[2018-08-03 02:34:44 +0000] [116] [ERROR] Retrying in 1 second.

[2018-08-03 02:34:45 +0000] [116] [ERROR] Can't connect to /tmp/gunicorn.sock

对于用户来说,这看起来像是权限错误,但这应该不是问题,因为gunicorn它以root


/opt/app # ps aux | grep gunicorn

  123 root      0:00 grep gunicorn

我也尝试过创建一个用户和一个组,addgroup -S appgroup && adduser -S appuser -G appgroup并/tmp/通过这样做来更改文件夹的权限chown appuser:appgroup /tmp/(因为gunicorn.sock未创建文件)。


操作系统中的内容正在按原样执行root,但仍然出现此错误。如何使通过gunicorn.sock文件运行它成为可能?


慕村9548890
浏览 183回答 1
1回答

Helenr

感谢https://github.com/benoitc/gunicorn/issues/1849上的人员。为了即时创建套接字,您可能必须将它们放入,/run/即bind='unix:/run/gunicron.sock'可以使用Nginx作为反向代理并通过给定的sock文件提供服务。但是为什么/run/呢?根据维基百科运行时变量数据:有关自上次引导以来正在运行的系统的信息,例如当前登录的用户和正在运行的守护程序。在启动过程开始时,必须删除或截断该目录下的文件;但是在提供此目录作为临时文件系统(tmpfs)的系统上,这不是必需的。有关更多信息,请参见https://unix.stackexchange.com/questions/13972/what-is-this-new-run-filesystem。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python