如何优雅的退出/关闭/重启gunicorn进程

阅读目录(Content)

1. 寻找masterpid
2. 重启Gunicorn任务
3. 退出Gunicorn任务
在工作中,会发现gunicorn启动的web服务,无论怎么使用kill -9 进程号都是无法杀死gunicorn,经过我一番百度和谷歌,发现想要删除gunicorn进程其实很简单。

回到顶部(go to top)
1. 寻找masterpid
通过执行如下命令,可以获取Gunicorn进程树:
pstree -ap|grep gunicorn

得到如下的结果。

|-grep,6194 –col gunicorn
| `-gunicorn,30080 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,4413 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,8030 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,8135 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,8137 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,11532 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,13460 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,19728 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,23585 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,23825 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,27921 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,28899 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,28900 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,28901 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,35637 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,36963 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,43074 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,43118 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,43232 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,43307 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,43308 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,44018 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,46996 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| |-gunicorn,47000 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
| `-gunicorn,47650 /usr/local/bin/gunicorn collect:app -c collect_gunicorn.py
很显然,30080就是Gunicorn的主进程。

回到顶部(go to top)
2. 重启Gunicorn任务
按照官方的推荐方法,很容易执行命令:

kill -HUP 30080
执行上述命令后,再次执行“pstree -ap|grep gunicorn”,我们很容易发现,除了主进程,其他的Gunicorn进程都已经销毁,并新建了进程(进程ID发生了变化)。

注意:网络资源有一定失效性,请以实际为准!
本站telegram群组 https://t.me/digter8 @digter8
仅供学习交流,严禁用于商业用途,请于24小时内删除。
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇