如何优雅的退出/关闭/重启gunicorn进程
在工作中,会发现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进程
在工作中,会发现gunicorn启动的web服务,无论怎么使用kill -9 进程号都是无法杀死gunicorn,经过我一番百度和谷歌,发现想要删除gunicorn进程其实很简单. 第一步获取Guni ...
- 是什么在.NET程序关闭时阻碍进程的退出?
在平时使用软件或是.NET程序开发的过程中,我们有时会遇到程序关闭后但进程却没有退出的情况,这往往预示着代码中有问题存在,不能正确的在程序退出时停止代码执行和销毁资源.这个现象有时并不容易被察觉,但在 ...
- GO学习-(39) 优雅地关机或重启
优雅地关机或重启 我们编写的Web项目部署之后,经常会因为需要进行配置变更或功能迭代而重启服务,单纯的kill -9 pid的方式会强制关闭进程,这样就会导致服务端当前正在处理的请求失败,那有没有更优 ...
- Go实现优雅关机与平滑重启
前言 优雅关机就是服务端关机命令发出后不是立即关机,而是等待当前还在处理的请求全部处理完毕后再退出程序,是一种对客户端友好的关机方式.而执行Ctrl+C关闭服务端时,会强制结束进程导致正在访问的请求出 ...
- python 如何优雅地退出子进程
python 如何优雅地退出子进程 主进程产生子进程,子进程进入永久循环模式.当主进程要求子进程退出时,如何能安全地退出子进程呢? 参考一些代码,我写了这个例子.运行之后,用kill pid试试.pi ...
- 如何优雅地退出python程序
如何优雅地退出python程序 一个单模的python程序,启动之后要能够优雅地关闭.即当用户按Ctrl+C或者kill pid的时候,程序都能从容关闭.实现起来非常简单. is_running = ...
- C# Note11:如何优雅地退出WPF应用程序
前言 I should know how I am supposed to exit my application when the user clicks on the Exit menu item ...
- Linux 两组信号对比(关闭和停止进程信号)
之前看信号的时候,没有太注意不同信号的对比.今天再次看到的时候,突然感觉对一些信号,非常相似,乃至非常容易混淆.今天周末就抽空总结一下. 一.关闭进程信号 常见的4中关闭进程信号是SIGKILL,SI ...
- 【springboot】之利用shell脚本优雅启动,关闭springboot服务
springbot开发api接口服务,生产环境中一般都是运行独立的jar,在部署过程中涉及到服务的优雅启动,关闭, springboot官方文档给出的有两种方式, 1.使用http shutdown ...
随机推荐
- 类型“System.Data.SQLite.SQLiteParameter”在未被引用的程序集中定义。必须添加对程序集“System.Data.SQLite, Version=1.0.66.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139”的引用
出现这个问题是 你的系统是64位 同时 dll生成的 any cpu 应该换为 x86
- Tensorflow异常集锦
一.tensorflow checkpoint报错 在调用tf.train.Saver#save时,如果使用的路径是绝对路径,那么保存的checkpoint里面用的就是绝对路径:如果使用的是相对路径, ...
- js中的getBoundingClientRect()函数
在Chrome上,此函数返回结果包含x,y,它们的取值对应于left,top.但是x,y这种表示方式非常不直观(需要先理解x轴和y轴的方向),而left,top则清晰无歧义地表达了元素的位置.正是因此 ...
- Java中timer的schedule()和schedualAtFixedRate()函数的区别
本文主要讨论java.util.Timer的schedule(timerTask,delay,period)和scheduleAtFixedRate(timerTask,delay,period)的区 ...
- Python 中的__new__和__init__的区别
[同] 二者均是Python面向对象语言中的函数,__new__比较少用,__init__则用的比较多. [异] __new__是在实例创建之前被调用的,因为它的任务就是创建实例然后返回该实例对象,是 ...
- iOS 对 HTTPS 证书链的验证
HTTPS从最终的数据解析的角度,与HTTP相同.HTTPS将HTTP协议数据包放到SSL/TSL层加密后,在TCP/IP层组成IP数据报去传输,以此保证传输数据的安全:而对于接收端,在SSL/TSL ...
- php数组使用json_encode函数中文被编码成null的原因和解决办法
大写的囧,提客户处理问题,前端的APP一直在叽叽咂咂,说收到的值是null,弄了半天原来是这个问题,记录下吧 json格式在开发中用的十分广泛.在php中json_encode函数可以直接将数组转成 ...
- zabbix3.0 安装时出现PHP Parse error: syntax error
httpd的错误日志 [Sun Mar :: ] [error] [client 由于系统yum默认安装的php版本是5.3.3 zabbix 3.0支持的平台,只支持php5.4以上的版本https ...
- 【Oracle】Oracle的内外连接
目录结构: contents structure [+] Oracle的内外连接 内连接 等值连接 非等值连接 自连接 外连接 外连接的特点 如何实现外连接 SQL99的内外连接 SQL99的内连接 ...
- 域名 ip地址 端口号
域名默认指定一个ip地址 当用域名访问网站的时候 网站会默认给个端口号80 或者自己指定 其他的 例如数据库 也是会给端口号 例如mysql 3306 域名:80 是访问iis 网站域名:3306 是 ...