要重现,请像这样启动 gunicorn:
gunicorn -w 1 --max-requests=0 --max-requests-jitter=10 -b 0.0.0.0:8000 api:app
然后将一些流量定向到它并观察以下日志输出:
[2019-02-05 20:27:23 +0000] [19] [INFO] Starting gunicorn 19.9.0
[2019-02-05 20:27:23 +0000] [19] [INFO] Listening at: http://0.0.0.0:8000 (19)
[2019-02-05 20:27:23 +0000] [19] [INFO] Using worker: sync
[2019-02-05 20:27:23 +0000] [22] [INFO] Booting worker with pid: 22
[2019-02-05 20:27:37 +0000] [22] [INFO] Autorestarting worker after current request.
[2019-02-05 20:27:37 +0000] [22] [INFO] Worker exiting (pid: 22)
[2019-02-05 20:27:37 +0000] [24] [INFO] Booting worker with pid: 24
我希望当--max-requests
设置为 0 时--max-requests-jitter
不起作用。
您期望的行为是什么? 通常, max-requests=0
应该意味着工作人员永远不会自动重启,但从您的日志中它看起来好像确实如此。
此错误已在 d4e1bfe5bd7801c160282310875c70cec15b7c07 中引入:
行self.max_requests = cfg.max_requests + jitter or MAXSIZE
现在self.max_requests = cfg.max_requests + jitter or sys.maxsize
自 e974f30517261b2bc95cfb2017a8688f367c8bf3 将设置self.max_requests
为 _jitter_ 值。
只有当它的设置值大于0时,我们才应该真正设置self.max_requests
。
@joekohlsdorf上面的补丁应该可以修复错误,但请告诉我们...
谢谢,我觉得不错。
最有用的评论
此错误已在 d4e1bfe5bd7801c160282310875c70cec15b7c07 中引入:
行
self.max_requests = cfg.max_requests + jitter or MAXSIZE
现在self.max_requests = cfg.max_requests + jitter or sys.maxsize
自 e974f30517261b2bc95cfb2017a8688f367c8bf3 将设置self.max_requests
为 _jitter_ 值。只有当它的设置值大于0时,我们才应该真正设置
self.max_requests
。