• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            Fork me on GitHub
            隨筆 - 215  文章 - 13  trackbacks - 0
            <2016年9月>
            28293031123
            45678910
            11121314151617
            18192021222324
            2526272829301
            2345678


            專注即時通訊及網游服務端編程
            ------------------------------------
            Openresty 官方模塊
            Openresty 標準模塊(Opm)
            Openresty 三方模塊
            ------------------------------------
            本博收藏大部分文章為轉載,并在文章開頭給出了原文出處,如有再轉,敬請保留相關信息,這是大家對原創作者勞動成果的自覺尊重!!如為您帶來不便,請于本博下留言,謝謝配合。

            常用鏈接

            留言簿(1)

            隨筆分類

            隨筆檔案

            相冊

            Awesome

            Blog

            Book

            GitHub

            Link

            搜索

            •  

            積分與排名

            • 積分 - 215430
            • 排名 - 118

            最新評論

            閱讀排行榜

            原文:Linux進程管理工具——supervisor

            介紹

            Supervisord是用Python實現的一款非常實用的進程管理工具

            安裝

            這里用源碼

            supervisor-3.1.3.tar.gz
            tar -zxvf supervisor-3.1.3.tar.gz
            cd supervisor-3.1.3
            sudo python setup.py install

            生成默認配置文件

            echo_supervisord_conf > /etc/supervisord.conf  

            修改默認配置文件

            如需允許web界面和命令行訪問,修改inet_http_server配置

            [inet_http_server]  
            port=*:9001     ;這里*表示可以讓其他終端訪問supervisor web界面
            username=username ;  用戶名  
            password=password  ;  密碼  

            未知  具體功能,需修復

            [supervisorctl]
            serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL  for a unix socket
            serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket

            修改進程

            復制代碼
            [program:test_http]
            command=python test_http.py 501  ; 被監控的進程路徑
            directory=/home/admin/soft/supervisor-3.1.3                ; 執行前要不要先cd到目錄去,一般不用
            priority=1                    ;數字越高,優先級越高
            numprocs=1                    ; 啟動幾個進程
            autostart=true                ; 隨著supervisord的啟動而啟動
            autorestart=true              ; 自動重啟。。當然要選上了
            startretries=10               ; 啟動失敗時的最多重試次數
            exitcodes=0                   ; 正常退出代碼(是說退出代碼是這個時就不再重啟了嗎?待確定)
            stopsignal=KILL               ; 用來殺死進程的信號
            stopwaitsecs=10               ; 發送SIGKILL前的等待時間
            redirect_stderr=true          ; 重定向stderr到stdout
            stdout_logfile=/home/jihite/log/supervisor.log
            復制代碼

            這里test_http.py 位于directory(/home/admin/soft/supervisor-3.1.3)目錄下

            test_http.py

            復制代碼
            import sys  
            import BaseHTTPServer  
            from SimpleHTTPServer import SimpleHTTPRequestHandler  
            HandlerClass = SimpleHTTPRequestHandler  
            ServerClass = BaseHTTPServer.HTTPServer  
            Protocol = "HTTP/1.0"  
              
            if __name__ == "__main__":
                if sys.argv[1:]:  
                    port = int(sys.argv[1])  
                else:  
                    port = 8000  
            
                server_address = ('10.125.24.105', port)  
                HandlerClass.protocol_version = Protocol  
                httpd = ServerClass(server_address, HandlerClass)  
                
                sa = httpd.socket.getsockname()  
                print "Serving HTTP on", sa[0], "port", sa[1], "..."  
                httpd.serve_forever() 
            復制代碼

            啟動

            sudo  supervisord -c /etc/supervisord.conf

            管理

            命令管理

            復制代碼
            sudo supervisorctl
            status: 查看當前運行的進程列表
            stop xxx: 停止某一個進程(xxx),xxx為[program:theprogramname]里配置的值。
            start xxx: 啟動某個進程
            restart xxx: 重啟某個進程
            stop groupworker: 重啟所有屬于名為groupworker這個分組的進程(start,restart同理)
            stop all,停止全部進程,注:start、restart、stop都不會載入最新的配置文件。
            
            復制代碼

            重新加載配置文件

            sudo  supervisorctl -c /etc/supervisord.conf

            界面管理

            異常

            1. Error: Another program is already listening on a port that one of our HTTP servers is configured to use. Shut this program down first before starting supervisord.

            For help, use /home/admin/idcp-check/virtualenv/bin/supervisord -h

            解決:(參考)

            sudo unlink /tmp/supervisor.sock
            or
            sudo unlink /var/run/supervisor.sock

            2. 啟動不起來

            $sudo supervisorctl 
            create_roadnet_tasks3 FATAL Exited too quickly (process log may have details)
            解決:(參考

            Check if supervisor startsecs=0   #被監控程序啟動時持續時間

            3. 啟動不起來,日志提示不能用root用戶啟動

            Running a worker with superuser privileges when the
            worker accepts messages serialized with pickle is a very bad idea!

            If you really want to continue then you have to set the C_FORCE_ROOT
            environment variable (but please think about this before you do).

            解決

            復制代碼
            from celery import Celery, platforms
            app = Celery('tasks', broker='amqp://myuser:
            mypassword@localhost :5672/vhost')
            platforms.C_FORCE_ROOT = True        #加上這一行

            @app.task def add(x, y): return x + y
            復制代碼

             

            posted on 2016-09-23 14:41 思月行云 閱讀(1157) 評論(0)  編輯 收藏 引用 所屬分類: 服務器\Ops
            新狼窝色AV性久久久久久| 人妻精品久久无码区| 久久婷婷五月综合97色| 国产精品美女久久福利网站| 久久人妻少妇嫩草AV无码蜜桃| 欧美色综合久久久久久| 久久乐国产精品亚洲综合| 国产精品欧美久久久久天天影视 | 伊人久久无码精品中文字幕| 99久久做夜夜爱天天做精品| 亚洲?V乱码久久精品蜜桃| 久久国产精品免费一区二区三区| 久久精品国产精品亚洲精品| 精品久久国产一区二区三区香蕉| 国产精品成人无码久久久久久| 久久久久夜夜夜精品国产| 中文字幕无码免费久久| 久久国产一片免费观看| 香蕉久久夜色精品国产尤物| 国产精品免费福利久久| 国产精品欧美亚洲韩国日本久久| 精品免费久久久久国产一区| 午夜精品久久久内射近拍高清| 久久精品国产亚洲AV香蕉| 久久久久亚洲精品男人的天堂| 欧美久久一区二区三区| 久久亚洲AV成人出白浆无码国产| 精品久久久久久综合日本| 久久天天躁狠狠躁夜夜av浪潮 | 久久亚洲精品成人无码网站| 久久久久99精品成人片试看| 久久久久国产精品嫩草影院| 久久久免费精品re6| 久久久久99精品成人片| 久久久久无码精品国产不卡| 久久久久九国产精品| 久久夜色精品国产网站| 人人狠狠综合久久亚洲高清| 久久超乳爆乳中文字幕| 久久久久亚洲AV无码去区首| 99精品国产在热久久无毒不卡|