如何優(yōu)雅的退出/關(guān)閉/重啟gunicorn進程

如何優(yōu)雅的退出/關(guān)閉/重啟gunicorn進程

閱讀目錄(Content)

在工作中堪遂,會發(fā)現(xiàn)gunicorn啟動的web服務看蚜,無論怎么使用kill -9 進程號都是無法殺死gunicorn,經(jīng)過我一番百度和谷歌栗弟,發(fā)現(xiàn)想要刪除gunicorn進程其實很簡單吐葵。

回到頂部(go to top)

1. 尋找masterpid

通過執(zhí)行如下命令规揪,可以獲取Gunicorn進程樹:
pstree -ap|grep gunicorn

得到如下的結(jié)果。

|-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的主進程猛铅。

回到頂部(go to top)

2. 重啟Gunicorn任務

按照官方的推薦方法,很容易執(zhí)行命令:

kill -HUP 30080

執(zhí)行上述命令后凤藏,再次執(zhí)行“pstree -ap|grep gunicorn”奸忽,我們很容易發(fā)現(xiàn),除了主進程揖庄,其他的Gunicorn進程都已經(jīng)銷毀栗菜,并新建了進程(進程ID發(fā)生了變化)。

回到頂部(go to top)

3. 退出Gunicorn任務

kill -9 30080
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末蹄梢,一起剝皮案震驚了整個濱河市疙筹,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌禁炒,老刑警劉巖而咆,帶你破解...
    沈念sama閱讀 219,188評論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異齐苛,居然都是意外死亡翘盖,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,464評論 3 395
  • 文/潘曉璐 我一進店門凹蜂,熙熙樓的掌柜王于貴愁眉苦臉地迎上來馍驯,“玉大人阁危,你說我怎么就攤上這事√保” “怎么了狂打?”我有些...
    開封第一講書人閱讀 165,562評論 0 356
  • 文/不壞的土叔 我叫張陵,是天一觀的道長混弥。 經(jīng)常有香客問我趴乡,道長,這世上最難降的妖魔是什么蝗拿? 我笑而不...
    開封第一講書人閱讀 58,893評論 1 295
  • 正文 為了忘掉前任晾捏,我火速辦了婚禮,結(jié)果婚禮上哀托,老公的妹妹穿的比我還像新娘惦辛。我一直安慰自己,他們只是感情好仓手,可當我...
    茶點故事閱讀 67,917評論 6 392
  • 文/花漫 我一把揭開白布胖齐。 她就那樣靜靜地躺著,像睡著了一般嗽冒。 火紅的嫁衣襯著肌膚如雪呀伙。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,708評論 1 305
  • 那天添坊,我揣著相機與錄音剿另,去河邊找鬼。 笑死帅腌,一個胖子當著我的面吹牛驰弄,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播速客,決...
    沈念sama閱讀 40,430評論 3 420
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼五鲫!你這毒婦竟也來了溺职?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,342評論 0 276
  • 序言:老撾萬榮一對情侶失蹤位喂,失蹤者是張志新(化名)和其女友劉穎浪耘,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體塑崖,經(jīng)...
    沈念sama閱讀 45,801評論 1 317
  • 正文 獨居荒郊野嶺守林人離奇死亡七冲,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,976評論 3 337
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了规婆。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片澜躺。...
    茶點故事閱讀 40,115評論 1 351
  • 序言:一個原本活蹦亂跳的男人離奇死亡蝉稳,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出掘鄙,到底是詐尸還是另有隱情耘戚,我是刑警寧澤,帶...
    沈念sama閱讀 35,804評論 5 346
  • 正文 年R本政府宣布操漠,位于F島的核電站收津,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏浊伙。R本人自食惡果不足惜撞秋,卻給世界環(huán)境...
    茶點故事閱讀 41,458評論 3 331
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望嚣鄙。 院中可真熱鬧吻贿,春花似錦、人聲如沸拗慨。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,008評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽赵抢。三九已至剧蹂,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間烦却,已是汗流浹背宠叼。 一陣腳步聲響...
    開封第一講書人閱讀 33,135評論 1 272
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留其爵,地道東北人冒冬。 一個月前我還...
    沈念sama閱讀 48,365評論 3 373
  • 正文 我出身青樓,卻偏偏與公主長得像摩渺,于是被迫代替她去往敵國和親简烤。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 45,055評論 2 355

推薦閱讀更多精彩內(nèi)容