{"id":76,"date":"2015-11-25T00:25:50","date_gmt":"2015-11-24T16:25:50","guid":{"rendered":"https:\/\/blog.espnlol.com\/?p=76"},"modified":"2016-01-12T22:13:52","modified_gmt":"2016-01-12T14:13:52","slug":"%e8%bf%9b%e7%a8%8b%e7%ae%a1%e7%90%86%e5%b7%a5%e5%85%b7%e4%b9%8bsupervisor","status":"publish","type":"post","link":"https:\/\/blog.espnlol.com\/?p=76","title":{"rendered":"\u8fdb\u7a0b\u7ba1\u7406\u5de5\u5177\u4e4bSupervisor"},"content":{"rendered":"<h2><b>\u9996\u5148Supervisor\u662f\u4e00\u4e2a\u8fdb\u7a0b\u76d1\u63a7\u53ca\u7ba1\u7406\u5de5\u5177\uff0c\u4e0emonit\u6709\u70b9\u76f8\u4f3c\u53c8\u4e0d\u4e00\u6837\uff0c\u540c\u6837\u53ef\u4ee5\u76d1\u63a7\u8fdb\u7a0b\uff0c\u81ea\u52a8\u91cd\u542f\u8fdb\u7a0b\u3002<\/b><\/h2>\n<h2><strong>\u6211\u7684\u9700\u6c42\uff1a\u5bf9\u4e00\u4e9b\u6ca1\u6709\u542f\u52a8\u811a\u672c\u7684\u7a0b\u5e8f\uff0c\u591a\u5b9e\u4f8b\u7a0b\u5e8f\u96c6\u4e2d\u7ba1\u7406\uff0c\u5e76\u968f\u65f6\u53ef\u4ee5\u901a\u8fc7\u9875\u9762\u91cd\u542f\u67d0\u4e2a\u7a0b\u5e8f\uff0c\u6bd4\u5982\u642c\u74e6\u5de5\u7684vps\uff0celk\uff0credis\uff0cjava\u8fdb\u7a0b\u7b49\u7b49\uff0c\u90fd\u9002\u7528\u3002\u597d\u4e86\uff0c\u5e9f\u8bdd\u4e0d\u591a\u8bf4\uff0c\u5f00\u59cb\u5b89\u88c5\u4f7f\u7528<\/strong><\/h2>\n<h3>1\uff0c\u5b89\u88c5supervisor\uff08centos\uff09<\/h3>\n<pre class=\"lang:vim decode:true\">yum install python-setuptools\r\neasy_install supervisor<\/pre>\n<p>\u6d4b\u8bd5\u662f\u5426\u5b89\u88c5\u6210\u529f\uff1a<\/p>\n<pre class=\"lang:vim decode:true\">echo_supervisord_conf<\/pre>\n<p>\u5b89\u88c5\u8fd8\u662f\u6bd4\u8f83\u7b80\u5355\uff0c\u5c312\u6761\u547d\u4ee4\uff0c\u5b89\u88c5\u5b8c\u6bd5\u4f1a\u591a\u51fa2\u4e2a\u547d\u4ee4supervisord\uff0csupervisorctl<\/p>\n<p>supervisord : supervisor\u7684\u670d\u52a1\u5668\u7aef\u90e8\u5206\uff0c\u542f\u52a8supervisor\u5c31\u662f\u8fd0\u884c\u8fd9\u4e2a\u547d\u4ee4<\/p>\n<p>supervisorctl\uff1a\u542f\u52a8supervisor\u7684\u547d\u4ee4\u884c\u7a97\u53e3\u3002<\/p>\n<p>2\uff0c\u521b\u5efa\u914d\u7f6e\u6587\u4ef6<\/p>\n<pre class=\"lang:vim decode:true \">echo_supervisord_conf &gt; \/etc\/supervisord.conf<\/pre>\n<p>\u6267\u884c\u4e4b\u540e\u4f1a\u5728\/etc\u4e0b\u751f\u6210\u914d\u7f6e\u6587\u4ef6supervisord.conf<\/p>\n<p>3\uff0c\u4fee\u6539\u914d\u7f6e\u6587\u4ef6<\/p>\n<p>\u5c06[inet_http_server]\u7684\u6ce8\u91ca\u5168\u90e8\u53bb\u6389\uff0c\u5728\u672b\u5c3e\u8ffd\u52a0\u4f60\u8981\u63a7\u5236\u7684\u8fdb\u7a0b,\u4e0b\u9762\u8d34\u51fa\u6211\u7684\u7cbe\u7b80\u914d\u7f6e<\/p>\n<pre class=\"lang:vim decode:true \">[unix_http_server]\r\nfile=\/tmp\/supervisor.sock   ; (the path to the socket file)\r\n\r\n[inet_http_server]         ; inet (TCP) server disabled by default\r\nport=192.168.216.236:8090        ; (ip_address:port specifier, *:port for all iface)\r\nusername=user              ; (default is no username (open server))\r\npassword=passwd               ; (default is no password (open server))\r\n\r\n[supervisord]\r\nlogfile=\/tmp\/supervisord.log ; (main log file;default $CWD\/supervisord.log)\r\nlogfile_maxbytes=50MB        ; (max main logfile bytes b4 rotation;default 50MB)\r\nlogfile_backups=10           ; (num of main logfile rotation backups;default 10)\r\nloglevel=info                ; (log level;default info; others: debug,warn,trace)\r\npidfile=\/tmp\/supervisord.pid ; (supervisord pidfile;default supervisord.pid)\r\nnodaemon=false               ; (start in foreground if true;default false)\r\nminfds=1024                  ; (min. avail startup file descriptors;default 1024)\r\nminprocs=200                 ; (min. avail process descriptors;default 200)\r\n\r\n[rpcinterface:supervisor]\r\nsupervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface\r\n\r\n[supervisorctl]\r\nserverurl=unix:\/\/\/tmp\/supervisor.sock ; use a unix:\/\/ URL  for a unix socket\r\n\r\n[program:ss_19999_server]\r\ncommand = ssserver -c \/etc\/shadowsocks.json\r\nautostart=true\r\nautorestart=true\r\n\r\n[program:ss_20001_server]\r\ncommand = ssserver -c \/etc\/shadowsocks1.json\r\nautostart=true\r\nautorestart=true\r\n\r\n[program:ss_20002_server]\r\ncommand = ssserver -c \/etc\/shadowsocks2.json\r\nautostart=true\r\nautorestart=true<\/pre>\n<h3>4\uff0c\u8fd0\u884csupervisord<\/h3>\n<p>\u7f16\u5199\u542f\u52a8\u811a\u672c<\/p>\n<pre class=\"lang:vim decode:true\">vi \/etc\/init.d\/supervisord\r\n#!\/bin\/bash\r\n#\r\n# supervisord   This scripts turns supervisord on\r\n#\r\n# Author:       Mike McGrath &lt;mmcgrath@redhat.com&gt; (based off yumupdatesd)\r\n#\r\n# chkconfig:    - 95 04\r\n#\r\n# description:  supervisor is a process control utility.  It has a web based\r\n#               xmlrpc interface as well as a few other nifty features.\r\n# processname:  supervisord\r\n# config: \/etc\/supervisord.conf\r\n# pidfile: \/var\/run\/supervisord.pid\r\n#\r\n\r\n# source function library\r\n. \/etc\/rc.d\/init.d\/functions\r\n\r\nRETVAL=0\r\n\r\nstart() {\r\n        echo -n $\"Starting supervisord: \"\r\n        daemon supervisord\r\n        RETVAL=$?\r\n        echo\r\n        [ $RETVAL -eq 0 ] &amp;&amp; touch \/var\/lock\/subsys\/supervisord\r\n}\r\n\r\nstop() {\r\n        echo -n $\"Stopping supervisord: \"\r\n        killproc supervisord\r\n        echo\r\n        [ $RETVAL -eq 0 ] &amp;&amp; rm -f \/var\/lock\/subsys\/supervisord\r\n}\r\n\r\nrestart() {\r\n        stop\r\n        start\r\n}\r\n\r\ncase \"$1\" in\r\n  start)\r\n        start\r\n        ;;\r\n  stop)\r\n        stop\r\n        ;;\r\n  restart|force-reload|reload)\r\n        restart\r\n        ;;\r\n  condrestart)\r\n        [ -f \/var\/lock\/subsys\/supervisord ] &amp;&amp; restart\r\n        ;;\r\n  status)\r\n        status supervisord\r\n        RETVAL=$?\r\n        ;;\r\n  *)\r\n        echo $\"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}\"\r\n        exit 1\r\nesac\r\n\r\nexit $RETVAL<\/pre>\n<p>\/etc\/init.d\/supervisord start<\/p>\n<p>PS:\u542f\u52a8\u4f1a\u62a5\u4e00\u4e9b\u9519\u8bef\uff0c\u4e0d\u8fc7\u4e0d\u5f71\u54cd\uff0c\u5b8c\u5168\u53ef\u4ee5\u5ffd\u7565\uff0c\u68c0\u67e5supervisord\u7ba1\u7406\u7684\u8fdb\u7a0b\u4ee5\u53ca8090\u7aef\u53e3\uff0c\u5982\u679c\u542f\u52a8\u5219\u4ee3\u8868\u6b63\u5e38<\/p>\n<h3>\u6216\u8005\u8fd0\u884c\u547d\u4ee4\uff1a<\/h3>\n<h3>supervisord\u00a0\u00a0\u00a0 \/\/\u542f\u52a8supervisor<\/h3>\n<h3>supervisorctl\u00a0\u00a0 \/\/\u6253\u5f00\u547d\u4ee4\u884c<\/h3>\n<h3>ctl\u4e2d\uff1a help\u00a0\u00a0 \/\/\u67e5\u770b\u547d\u4ee4<\/h3>\n<h3>ctl\u4e2d\uff1a status\u00a0 \/\/\u67e5\u770b\u72b6\u6001<\/h3>\n<p>5\uff0cweb\u7ba1\u7406<\/p>\n<p>\u6253\u5f00\u7ba1\u7406\u9875\u9762\uff0c\u53ef\u4ee5\u770b\u5230\u8fdb\u7a0b\u542f\u52a8\u65f6\u95f4\uff0c\u53ef\u4ee5\u624b\u52a8\u64cd\u4f5c\u91cd\u542f\uff0clog\u53ea\u8bb0\u5f55\u62a5\u9519\u4fe1\u606f\uff0c\u5982\u679c\u8fdb\u7a0b\u6709\u95ee\u9898\u4f1a\u6253\u5370\u9519\u8bef\u65e5\u5fd7\u3002<\/p>\n<p><a href=\"https:\/\/blog.espnlol.com\/wp-content\/uploads\/2015\/11\/supervisor.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-77\" src=\"https:\/\/blog.espnlol.com\/wp-content\/uploads\/2015\/11\/supervisor.png\" alt=\"supervisor\" width=\"1666\" height=\"508\" srcset=\"https:\/\/blog.espnlol.com\/wp-content\/uploads\/2015\/11\/supervisor.png 1666w, https:\/\/blog.espnlol.com\/wp-content\/uploads\/2015\/11\/supervisor-300x91.png 300w, https:\/\/blog.espnlol.com\/wp-content\/uploads\/2015\/11\/supervisor-1024x312.png 1024w\" sizes=\"auto, (max-width: 1666px) 100vw, 1666px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9996\u5148Supervisor\u662f\u4e00\u4e2a\u8fdb\u7a0b\u76d1\u63a7\u53ca\u7ba1\u7406\u5de5\u5177\uff0c\u4e0emonit\u6709\u70b9\u76f8\u4f3c\u53c8\u4e0d\u4e00\u6837\uff0c &hellip; <a href=\"https:\/\/blog.espnlol.com\/?p=76\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[],"class_list":["post-76","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=\/wp\/v2\/posts\/76","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=76"}],"version-history":[{"count":2,"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=\/wp\/v2\/posts\/76\/revisions"}],"predecessor-version":[{"id":106,"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=\/wp\/v2\/posts\/76\/revisions\/106"}],"wp:attachment":[{"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=76"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=76"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=76"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}