为什么gunicorn经常告诉我它有4个工人?

时间:2014-09-26 09:23:36

标签: gunicorn

我刚刚将gunicorn升级到19.1.1,日志看起来很奇怪。日志级别设置为debug,它看起来像这样:

[2014-09-26 08:50:51 +0000] [13830] [INFO] Starting gunicorn 19.1.1
[2014-09-26 08:50:51 +0000] [13830] [DEBUG] Arbiter booted
[2014-09-26 08:50:51 +0000] [13830] [INFO] Listening at: http://127.0.0.1:8000 (13830)
[2014-09-26 08:50:51 +0000] [13830] [INFO] Using worker: eventlet
[2014-09-26 08:50:51 +0000] [13848] [INFO] Booting worker with pid: 13848
[2014-09-26 08:50:51 +0000] [13852] [INFO] Booting worker with pid: 13852
[2014-09-26 08:50:51 +0000] [13854] [INFO] Booting worker with pid: 13854
[2014-09-26 08:50:51 +0000] [13855] [INFO] Booting worker with pid: 13855
[2014-09-26 08:50:51 +0000] [13830] [DEBUG] 4 workers
[2014-09-26 08:52:51 +0000] [13830] [DEBUG] 4 workers
[2014-09-26 08:54:50 +0000] [13830] [DEBUG] 4 workers
[2014-09-26 08:56:49 +0000] [13830] [DEBUG] 4 workers
[2014-09-26 08:58:48 +0000] [13830] [DEBUG] 4 workers
[2014-09-26 09:00:48 +0000] [13830] [DEBUG] 4 workers
[2014-09-26 09:02:47 +0000] [13830] [DEBUG] 4 workers
[2014-09-26 09:04:46 +0000] [13830] [DEBUG] 4 workers
[2014-09-26 09:06:45 +0000] [13830] [DEBUG] 4 workers
[2014-09-26 09:08:44 +0000] [13830] [DEBUG] 4 workers
[2014-09-26 09:10:44 +0000] [13830] [DEBUG] 4 workers
[2014-09-26 09:12:43 +0000] [13830] [DEBUG] 4 workers
[2014-09-26 09:14:43 +0000] [13830] [DEBUG] 4 workers
[2014-09-26 09:16:42 +0000] [13830] [DEBUG] 4 workers

发生了什么事?

1 个答案:

答案 0 :(得分:4)

这是让它处于调试模式的所有部分。

此日志由gunicorn.arbiter.manage_workers()在495

生成

https://github.com/benoitc/gunicorn/blob/e0b3c42dd2c31b2f60abd6833401bd8eed116dc6/gunicorn/arbiter.py#L495

这在主循环期间调用:

https://github.com/benoitc/gunicorn/blob/e0b3c42dd2c31b2f60abd6833401bd8eed116dc6/gunicorn/arbiter.py#L165

如果有信号,也会在每个信号后调用它。

如果你可以通过manage_workers()的arbiter.py文件,你会看到调用它的位置和方式。

干杯 乔