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

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的主进程。

2. 重启Gunicorn任务

按照官方的推荐方法,很容易执行命令:

kill -HUP 30080

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

3. 退出Gunicorn任务

kill -9 30080

原文网址:优雅的退出/关闭/重启gunicorn进程

如何优雅的退出/关闭/重启gunicorn进程的更多相关文章

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

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

  2. 是什么在.NET程序关闭时阻碍进程的退出?

    在平时使用软件或是.NET程序开发的过程中,我们有时会遇到程序关闭后但进程却没有退出的情况,这往往预示着代码中有问题存在,不能正确的在程序退出时停止代码执行和销毁资源.这个现象有时并不容易被察觉,但在 ...

  3. GO学习-(39) 优雅地关机或重启

    优雅地关机或重启 我们编写的Web项目部署之后,经常会因为需要进行配置变更或功能迭代而重启服务,单纯的kill -9 pid的方式会强制关闭进程,这样就会导致服务端当前正在处理的请求失败,那有没有更优 ...

  4. Go实现优雅关机与平滑重启

    前言 优雅关机就是服务端关机命令发出后不是立即关机,而是等待当前还在处理的请求全部处理完毕后再退出程序,是一种对客户端友好的关机方式.而执行Ctrl+C关闭服务端时,会强制结束进程导致正在访问的请求出 ...

  5. python 如何优雅地退出子进程

    python 如何优雅地退出子进程 主进程产生子进程,子进程进入永久循环模式.当主进程要求子进程退出时,如何能安全地退出子进程呢? 参考一些代码,我写了这个例子.运行之后,用kill pid试试.pi ...

  6. 如何优雅地退出python程序

    如何优雅地退出python程序 一个单模的python程序,启动之后要能够优雅地关闭.即当用户按Ctrl+C或者kill pid的时候,程序都能从容关闭.实现起来非常简单. is_running = ...

  7. C# Note11:如何优雅地退出WPF应用程序

    前言 I should know how I am supposed to exit my application when the user clicks on the Exit menu item ...

  8. Linux 两组信号对比(关闭和停止进程信号)

    之前看信号的时候,没有太注意不同信号的对比.今天再次看到的时候,突然感觉对一些信号,非常相似,乃至非常容易混淆.今天周末就抽空总结一下. 一.关闭进程信号 常见的4中关闭进程信号是SIGKILL,SI ...

  9. 【springboot】之利用shell脚本优雅启动,关闭springboot服务

    springbot开发api接口服务,生产环境中一般都是运行独立的jar,在部署过程中涉及到服务的优雅启动,关闭, springboot官方文档给出的有两种方式, 1.使用http shutdown ...

随机推荐

  1. 【js+jquery】通用、简单的JS 提示框

    1.该插件不需要依赖 jquery,仅仅使用了原生js 2.简单.通用.可自定义修改样式.支持等待N秒消失.支持消失后跳转其他url , 功能还是比较完善的. 3.不废话,上代码: (我存放的位置在 ...

  2. Easyui入门视频教程 第06集---Layout初始化和属性方法使用

    目录 ----------------------- Easyui入门视频教程 第09集---登录完善 图标自定义   Easyui入门视频教程 第08集---登录实现 ajax button的使用  ...

  3. iOS 10 的一个重要更新-用 UIViewPropertyAnimator 编写动画

    曾经的黑暗年代 用基于 block 的 UIView animation 来编写 view 属性(frame, transform 等等)变化的动画非常简单.只需要短短几行代码: view.alpha ...

  4. LVS负载均衡之持久性连接介绍(session篇)

    在实际生产环境中,往往需要根据业务应用场景来设置lvs的会话超时时间以及防session连接丢失的问题提,如在业务支付环节,如若session丢失会导致重复扣款问题,严重影响到安全性,本小节解将会讲到 ...

  5. Ant scp upload文件至linux server(用java调用Ant api)

    1.要准备的jar包:ant.jar,ant-jsch.jar code: package com.test.utils; import org.apache.tools.ant.Project; i ...

  6. webpack window下配置的hello world

    峰回路转 一区九折 先看效果:(此效果是webpack执行完之后会生成build文件夹已经它下面的index.html,点击index.html就是下图的效果)

  7. PHP中使用 JKS(Java Key Store)的方法

    PHP语言无法直接读取 JKS中的密钥,需要通过以下方法进行转换 本例以JKS中的私钥为例 首先 使用 KeyStore Explorer工具,打开JKS文件 ,此时可能需要输入 JKS密码 对私钥进 ...

  8. KnockoutJs学习笔记

    1.缘由 新公司前端用的是Jquery+Knockout,Knockout只知道是MVVM,未曾接触.报到前,先学习下. 2.前置知识 MVVM模式介绍 MVVM:模型-视图-视图模型(Model-V ...

  9. MySQL -- Fast Index Creation

    1.fast index creation简介 MySQL5.5之后,对innodb表创建或删除辅助索引的效率提升了很多,即增加了新的功能fast index creation.因为MySQL5.5之 ...

  10. cassandra java 兼容性问题及其解决方法

    1.安装 http://wiki.apache.org/cassandra/DebianPackaging 2.java兼容性问题 由于cassandra运行于sun jdk6上,而ubuntu默认是 ...