如何优雅的退出/关闭/重启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 ...
随机推荐
- Iterm2的一些好用法
今天把mac带到公司办公了,爽歪歪啊. 1,如何脱离鼠标拷贝屏幕中的内容 1) Command+f 调出选择框,并在其中输入要复制的字符,可以使用Tab补全 2) 按 Command + c复制字符 ...
- iOS 获取摄像头当前方向
在做二维码扫描和直播获取视频流的过程中,可能会用到 AVCaptureDevice AVCaptureVideoPreviewLayer AVCaptureSession 这几个参数,其中 1.定义显 ...
- ILP32、ILP64、LP64、LLP64、64位系统
Data Type ILP32 ILP64 LP64 LLP64char 8 8 8 ...
- JavaScript 错误处理, Throw、Try 和 Catch入门
try 语句测试代码块的错误. catch 语句处理错误. throw 语句创建自定义错误. 错误一定会发生 当 JavaScript 引擎执行 JavaScript 代码时,会发生各种错误: 可能是 ...
- 【LeetCode】203. Remove Linked List Elements
Remove Linked List Elements Remove all elements from a linked list of integers that have value val. ...
- Linux操作系统中文件结构stat中st_size的说明以及对于文件中洞(Holes)的理解
文件stat结构体中st_size成员 对于所有的文件类型,st_size成员对其中的普通文件.目录以及符号链接有实在的意义.其中,对于普通文件而言,st_size记录了该文件的实际大小:对于目录而言 ...
- php性能分析工具xhprof
安装方法: wget http://pecl.php.net/get/xhprof-0.9.x.tgz cp xhprof-0.9.x.tgz /home/www/xhprof.tgz tar zxv ...
- VC下加载JPG/GIF/PNG图片的两种方法
转载自:http://blog.sina.com.cn/s/blog_6582aa410100huil.html 仅管VC有提供相应的API和类来操作bmp位图.图标和(增强)元文件,但却不支持jpg ...
- 跟我学SharePoint 2013视频培训课程——签出、签入文档(9)
课程简介 第9天,怎样在SharePoint 2013中签出.签入文档 视频 SharePoint 2013 交流群 41032413
- [转]What are mode and status columns under gp_segment_configuration table
February 16, 2017 10:39 Goal In this article we will try to understand and answer to the below two q ...