• <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

            搜索

            •  

            積分與排名

            • 積分 - 217495
            • 排名 - 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 思月行云 閱讀(1167) 評論(0)  編輯 收藏 引用 所屬分類: 服務器\Ops
            青草久久久国产线免观| 无码超乳爆乳中文字幕久久| 久久91亚洲人成电影网站| 久久精品天天中文字幕人妻| 国产精品一区二区久久不卡| 久久久久综合网久久| 综合久久一区二区三区 | 久久久久亚洲精品日久生情 | 久久精品成人影院| 久久久国产打桩机| 久久精品国产精品亚洲人人| 亚洲中文字幕无码久久综合网| 97久久国产亚洲精品超碰热| 国产精品综合久久第一页| 五月丁香综合激情六月久久| 精品久久久久久无码人妻蜜桃| 久久久久亚洲AV无码观看| 国产成人精品久久| 精品久久久久久无码专区不卡| 久久青青草原精品国产软件| 久久精品中文无码资源站| 久久久精品国产| 久久99热这里只有精品国产| 精品久久久久香蕉网| 久久久久久久97| 免费精品国产日韩热久久| 久久久久久无码国产精品中文字幕 | 99久久综合狠狠综合久久止| 国产A三级久久精品| 性做久久久久久久久| 久久国产香蕉一区精品| 日本精品久久久久中文字幕8| 亚洲午夜久久久久久久久久| 久久亚洲精品无码VA大香大香| 久久久久久无码国产精品中文字幕| 久久精品国内一区二区三区| 久久成人精品视频| 欧美伊香蕉久久综合类网站| 中文字幕久久欲求不满| AA级片免费看视频久久| 国产高潮国产高潮久久久91 |