JakobHu 2018-04-23
Gunicorn - 绿色独角兽(Green Unicorn),是一个Python WSGI UNIX的HTTP服务器。Gunicorn主要是预先fork进程,实现多进程处理请求,提升web的性能。Gunicorn服务器广泛兼容各种web框架,简单地实现,服务器资源,和相当迅速。
启动Gunicorn之后,会发现gunicorn启动的web服务,无论怎么使用kill -9 进程号都是无法杀死gunicorn,因为是预先fork,只要一个进程死掉就会重新拉起另一个进程,这时候就需要找到父进程,发送kill信号。
1、获取进程树
pstree -ap|grep gunicorn
| | |-grep,14519 --color=auto gunicorn
| `-gunicorn,8137 opt/gunicorn/bin/gunicorn opwebs.wsgi:application -c ...
| |-gunicorn,8326 /opt/gunicorn/bin/gunicorn opwebs.wsgi:application -c ...
| | |-{gunicorn},8329
| | |-{gunicorn},8330
| | |-{gunicorn},8331
| | |-{gunicorn},8332
| | |-{gunicorn},8333
| | |-{gunicorn},8334
| | |-{gunicorn},8336
| | |-{gunicorn},8337
| | |-{gunicorn},8338
| | |-{gunicorn},8339
| | |-{gunicorn},8340
| | |-{gunicorn},8341
| | |-{gunicorn},8342
| | |-{gunicorn},8343
| | `-{gunicorn},8344
2、重启进程
kill -HUP 8326
#重启之后可以看到父进程PID是不变的,子进程会生成新的PID
3、关闭进程
kill -9 8137
username=user ; should be same as http_username if set. password=123 ; should be same as http_passwo