我正在用gunicorn和超级用户运行django服务器。
这是我的主管朋友,
[program:api]
process_name=api
command=command-to-run
user=api
directory=/opt/api/api
redirect_stderr=true
stderr_logfile=/var/log/api/stderr.log
stdout_logfile=/var/log/api/stdout.log
autostart=true
autorestart=true
logfile_maxbytes = 50MB
logfile_backups = 10
stopsignal=HUP
当我运行sudo supervisorctl
时,
:/var/log/consumer_api$ sudo supervisorctl
api RUNNING pid 1674, uptime 3:13:29
>
当我在主管api
中重新启动我的sudo supervisorctl restart api
应用程序时,这里是gunicorn日志
[2019-02-14 16:09:02 +0000] [25740] [INFO] Handling signal: hup
[2019-02-14 16:09:02 +0000] [25740] [INFO] Hang up: Master
[2019-02-14 16:09:02 +0000] [1593] [INFO] Booting worker with pid: 1593
[2019-02-14 16:09:02 +0000] [1594] [INFO] Booting worker with pid: 1594
[2019-02-14 16:09:02 +0000] [1597] [INFO] Booting worker with pid: 1597
[2019-02-14 16:09:02 +0000] [1595] [INFO] Booting worker with pid: 1595
[2019-02-14 16:09:02 +0000] [1596] [INFO] Booting worker with pid: 1596
[2019-02-14 16:09:02 +0000] [1598] [INFO] Booting worker with pid: 1598
[2019-02-14 21:39:02 +0530] [25756] [INFO] Worker exiting (pid: 25756)
[2019-02-14 21:39:02 +0530] [25758] [INFO] Worker exiting (pid: 25758)
[2019-02-14 21:39:02 +0530] [25759] [INFO] Worker exiting (pid: 25759)
[2019-02-14 21:39:02 +0530] [25760] [INFO] Worker exiting (pid: 25760)
[2019-02-14 21:39:02 +0530] [25769] [INFO] Worker exiting (pid: 25769)
[2019-02-14 21:39:02 +0530] [25773] [INFO] Worker exiting (pid: 25773)
[2019-02-14 21:39:02 +0530] [7029] [INFO] Worker exiting (pid: 7029)
[2019-02-14 21:39:02 +0530] [7336] [INFO] Worker exiting (pid: 7336)
[2019-02-14 16:09:02 +0000] [1607] [INFO] Booting worker with pid: 1607
[2019-02-14 16:09:02 +0000] [1605] [INFO] Booting worker with pid: 1605
[2019-02-14 16:09:02 +0000] [1606] [INFO] Booting worker with pid: 1606
[2019-02-14 21:39:02 +0530] [25767] [INFO] Worker exiting (pid: 25767)
[2019-02-14 21:39:12 +0530] [1593] [INFO] Parent changed, shutting down: <Worker 1593>
[2019-02-14 21:39:12 +0530] [1593] [INFO] Worker exiting (pid: 1593)
[2019-02-14 16:09:12 +0000] [1674] [INFO] Starting gunicorn 19.8.1
[2019-02-14 16:09:12 +0000] [1674] [ERROR] Connection in use: ('127.0.0.1', 8000)
[2019-02-14 16:09:12 +0000] [1674] [ERROR] Retrying in 1 second.
[2019-02-14 21:39:12 +0530] [1605] [INFO] Parent changed, shutting down: <Worker 1605>
[2019-02-14 21:39:12 +0530] [1605] [INFO] Worker exiting (pid: 1605)
[2019-02-14 21:39:12 +0530] [1596] [INFO] Parent changed, shutting down: <Worker 1596>
[2019-02-14 21:39:12 +0530] [1596] [INFO] Worker exiting (pid: 1596)
[2019-02-14 21:39:12 +0530] [1595] [INFO] Parent changed, shutting down: <Worker 1595>
[2019-02-14 21:39:12 +0530] [1595] [INFO] Worker exiting (pid: 1595)
[2019-02-14 21:39:12 +0530] [1606] [INFO] Parent changed, shutting down: <Worker 1606>
[2019-02-14 21:39:12 +0530] [1606] [INFO] Worker exiting (pid: 1606)
[2019-02-14 21:39:13 +0530] [1594] [INFO] Parent changed, shutting down: <Worker 1594>
[2019-02-14 21:39:13 +0530] [1594] [INFO] Worker exiting (pid: 1594)
[2019-02-14 16:09:13 +0000] [1674] [ERROR] Connection in use: ('127.0.0.1', 8000)
[2019-02-14 16:09:13 +0000] [1674] [ERROR] Retrying in 1 second.
[2019-02-14 21:39:13 +0530] [1597] [INFO] Parent changed, shutting down: <Worker 1597>
[2019-02-14 21:39:13 +0530] [1597] [INFO] Worker exiting (pid: 1597)
[2019-02-14 21:39:14 +0530] [1598] [INFO] Parent changed, shutting down: <Worker 1598>
[2019-02-14 21:39:14 +0530] [1598] [INFO] Worker exiting (pid: 1598)
[2019-02-14 21:39:14 +0530] [1607] [INFO] Parent changed, shutting down: <Worker 1607>
[2019-02-14 21:39:14 +0530] [1607] [INFO] Worker exiting (pid: 1607)
[2019-02-14 16:09:14 +0000] [1674] [ERROR] Connection in use: ('127.0.0.1', 8000)
[2019-02-14 16:09:14 +0000] [1674] [ERROR] Retrying in 1 second.
[2019-02-14 16:09:15 +0000] [1674] [INFO] Listening at: http://127.0.0.1:8000 (1674)
[2019-02-14 16:09:15 +0000] [1674] [INFO] Using worker: sync
[2019-02-14 16:09:15 +0000] [1674] [INFO] Server is ready. Spawning workers
[2019-02-14 16:09:15 +0000] [1684] [INFO] Booting worker with pid: 1684
[2019-02-14 16:09:15 +0000] [1686] [INFO] Booting worker with pid: 1686
[2019-02-14 16:09:15 +0000] [1688] [INFO] Booting worker with pid: 1688
[2019-02-14 16:09:15 +0000] [1689] [INFO] Booting worker with pid: 1689
[2019-02-14 16:09:15 +0000] [1690] [INFO] Booting worker with pid: 1690
[2019-02-14 16:09:15 +0000] [1691] [INFO] Booting worker with pid: 1691
[2019-02-14 16:09:15 +0000] [1692] [INFO] Booting worker with pid: 1692
[2019-02-14 16:09:15 +0000] [1694] [INFO] Booting worker with pid: 1694
[2019-02-14 16:09:15 +0000] [1697] [INFO] Booting worker with pid: 1697
我正在将HUP
发送到我的gunicorn进程,因此它应正常关闭之前的请求,然后仅在正确重新加载后才接受新请求。
但是我的API仍然得到502,500。
我知道我们可以做kill -HUP pid
,但是当我更改主管配置并必须执行reread
和update
时,这没有帮助。
sudo supervisorctl signal hup api
也可以正常工作,但是再次,当我更改主管配置时,它又遇到了问题。然后,我再次必须执行reread
和update
,并且update
导致重新启动,并且我再次将请求丢失给502。
在文档中,主管提到了stopsignal
,但是却没有这样做,为什么会这样?