linux下supervisord的簡單使用__linux

來源:互聯網
上載者:User

supervisord的介紹:http://supervisord.org/introduction.html

簡單來講:守護進程,如果你的進程一直在運行,突然掛了。
那麼supervisord能幫你速度拉起這個進程,使之正常運行

1:安裝supervisord

easy_install supervisor

2:設定檔 “echo_supervisord_conf”命令來組建組態檔案,例

echo_supervisord_conf > /etc/supervisord.conf

3:組態管理的進程

在 /etc/supervisord.conf 最後加上這兩句[program:python]command=python /tmp/test.py
/tmp/test.py的檔案內容#!/usr/bin/python# -*- coding: UTF-8 -*-import timewhile(True):    # 3秒    time.sleep(1)    # 開啟檔案    fo = open("/tmp/test.txt", "a")    print "檔案名稱為: ", fo.name    str = time.ctime() + "\n"    fo.write( str )    # 關閉檔案    fo.close()

5:啟動supervisord

supervisord #斷行符號即啟動  -h 下可以看下參數的具體配置

6:查看 python的進程

可以看到 /tmp/test.txt 裡面的內容在增加

7:現在收到殺掉python test.py這個進程

kill -9 5535 殺死python test.py這個進程

然後再去查看進程 馬上就可以看到 python test.py又出現了
看下 進程號 已經變成了5592 這樣supervisord就可以起到守護進程的作用了

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.