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

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

第一步获取Gunicorn进程树:

通过执行如下命令,可以获取Gunicorn进程树:

pstree -ap|grep gunicorn
得到的结果如下

Python
 |   |                       |-grep,14519 --color=auto gunicorn
  |           `-gunicorn,28097 /usr/local/bin/gunicorn query_site.wsgi:application -c ...
  |               |-gunicorn,14226 /usr/local/bin/gunicorn query_site.wsgi:application -c ...
  |               |   |-{gunicorn},14229
  |               |   |-{gunicorn},14230
  |               |   |-{gunicorn},14231
  |               |   |-{gunicorn},14232
  |               |   |-{gunicorn},14233
  |               |   |-{gunicorn},14234
  |               |   |-{gunicorn},14236
  |               |   |-{gunicorn},14237
  |               |   |-{gunicorn},14238
  |               |   |-{gunicorn},14239
  |               |   |-{gunicorn},14240
  |               |   |-{gunicorn},14241
  |               |   |-{gunicorn},14242
  |               |   |-{gunicorn},14243
  |               |   `-{gunicorn},14244
2. 重启Gunicorn任务

Python
kill -HUP 14226
3. 退出Gunicorn任务

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

  

转载于:https://www.cnblogs.com/hedianzhan/p/9655119.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值