{"id":996,"date":"2018-08-30T20:00:11","date_gmt":"2018-08-30T12:00:11","guid":{"rendered":"https:\/\/blog.jsjs.org\/?p=996"},"modified":"2018-08-30T20:00:11","modified_gmt":"2018-08-30T12:00:11","slug":"centos7-supervisor%e5%ae%89%e8%a3%85%e9%85%8d%e7%bd%ae%e5%ae%9e%e6%88%98","status":"publish","type":"post","link":"https:\/\/blog.jsjs.org\/?p=996","title":{"rendered":"CentOS7\u2014\u2014supervisor\u5b89\u88c5\u914d\u7f6e\u5b9e\u6218"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"\u4ecb\u7ecd\">\u4ecb\u7ecd<\/h2>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>Supervisor\u662f\u4e00\u4e2a\u8fdb\u7a0b\u63a7\u5236\u7cfb\u7edf\u3002 \u5b83\u662f\u4e00\u4e2aC\/S\u7cfb\u7edf,\u670d\u52a1\u7aef\u662fsupervisord\u8fdb\u7a0b\uff0c\u63a7\u5236\u7aef\u4f7f\u7528supervisorctl\u6765\u8fdb\u884c\u63a7\u5236\u542f\u52a8\u8fdb\u7a0b\u3002\u540c\u65f6\u5b83\u4e5f\u63d0\u4f9b\u4e86\u4e00\u4e2aweb\u754c\u9762\uff0c\u6765\u53ef\u4ee5\u4f7f\u6211\u4eec\u65b9\u4fbf\u7684\u8fdb\u884c\u8fdb\u7a0b\u7684\u63a7\u5236\u548c\u67e5\u770b\u65e5\u5fd7\u4fe1\u606f\u3002<\/p><p>supervisord\u548csupervisorctl\u7c7b\u4f3c\u4e8ecentos7\u4e0a\u7684systemd\u548csystemctl\u7684\u5173\u7cfb\uff0c\u4f46\u662f\u53c8\u548csystemd\u4e0d\u540c\uff0c \u4f60\u7684Nginx\uff0cTomcat\uff0cmemcache\uff0cRedis\u2026\u4f1a\u5d29\u4e48\uff1f \u90a3\u4f60\u81ea\u5df1\u5199\u7684\u670d\u52a1\u5668\u76d1\u6d4b\u811a\u672c\u5462\uff1f \u597d\u5427\u3001\u4e0d\u8981\u518d\u7ea0\u7ed3\u4e86\u3001\u4ea4\u7ed9Supervisor\u5427! \u5b83\u4f1a\u5e2e\u4f60\u7ef4\u62a4\u8fd9\u4e9b\u3001\u5373\u4f7f\u5b83\u4eec\u4e0d\u5c0f\u5fc3\u5d29\u4e86\u3001Supervisor\u4f1a\u5e2e\u4f60\u770b\u4f4f\u5b83\u4eec\u3001\u7ef4\u62a4\u5b83\u4eec\uff0c\u91cd\u542f\u5b83\u4eec\u3002<\/p><\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u4e00\u5b89\u88c5\">\u4e00\u3001\u5b89\u88c5<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5b89\u88c5\u73af\u5883\uff1aCentOS7.3<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>yum install python-setuptools\neasy_install supervisor\n#\u6216\u8005\u662f\npip install supervisor<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>supervisor\u5b89\u88c5\u5b8c\u6210\u540e\u4f1a\u751f\u6210\u4e09\u4e2a\u6267\u884c\u7a0b\u5e8f\uff1asupervisortd\u3001supervisorctl\u3001echo_supervisord_conf\uff0c\u5206\u522b\u662fsupervisor\u7684\u5b88\u62a4\u8fdb\u7a0b\u670d\u52a1\uff08\u7528\u4e8e\u63a5\u6536\u8fdb\u7a0b\u7ba1\u7406\u547d\u4ee4\uff09\u3001\u5ba2\u6237\u7aef\uff08\u7528\u4e8e\u548c\u5b88\u62a4\u8fdb\u7a0b\u901a\u4fe1\uff0c\u53d1\u9001\u7ba1\u7406\u8fdb\u7a0b\u7684\u6307\u4ee4\uff09\u3001\u751f\u6210\u521d\u59cb\u914d\u7f6e\u6587\u4ef6\u7a0b\u5e8f\u3002<\/p><\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u4e8c\u914d\u7f6e\">\u4e8c\u3001\u914d\u7f6e<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u8f93\u51fasupervisor\u914d\u7f6e\uff0c\u53ef\u4ee5\u4f7f\u7528<code>echo_supervisord_conf<\/code>,\u6211\u4eec\u5c06\u5176\u91cd\u5b9a\u5411\u5230\u6587\u4ef6\u4e2d\uff0c\u7136\u540e\u5c31\u53ef\u4ee5\u4fee\u6539\u5176\u914d\u7f6e\u9879\u4e86\u3002\u00a0<br\/>\u8fd0\u884csupervisord\u670d\u52a1\u7684\u65f6\u5019\uff0c\u9700\u8981\u6307\u5b9asupervisor\u914d\u7f6e\u6587\u4ef6\uff0c\u5982\u679c\u6ca1\u6709\u663e\u793a\u6307\u5b9a\uff0c\u9ed8\u8ba4\u5728\u4ee5\u4e0b\u76ee\u5f55\u67e5\u627e\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>###$CWD\u8868\u793a\u8fd0\u884csupervisord\u7a0b\u5e8f\u7684\u76ee\u5f55\u3002\n$CWD\/supervisord.conf\n$CWD\/etc\/supervisord.conf\n\/etc\/supervisord.conf\n\/etc\/supervisor\/supervisord.conf (since Supervisor 3.3.0)\n..\/etc\/supervisord.conf (Relative to the executable)\n..\/supervisord.conf (Relative to the executable)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u5c06\u5176\u91cd\u5b9a\u5411\u5230\/etc\/\u76ee\u5f55\u4e0b\u9762<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mkdir \/etc\/supervisor\necho_supervisord_conf > \/etc\/supervisor\/supervisord.conf<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"1\u914d\u7f6e\u6587\u4ef6\u53c2\u6570\u8bf4\u660e\">1\u3001\u914d\u7f6e\u6587\u4ef6\u53c2\u6570\u8bf4\u660e<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">supervisor\u7684\u914d\u7f6e\u53c2\u6570\u8f83\u591a\uff0c\u4e0b\u9762\u4ecb\u7ecd\u4e00\u4e0b\u5e38\u7528\u7684\u53c2\u6570\u914d\u7f6e\uff0c\u8be6\u7ec6\u7684\u914d\u7f6e\u53ca\u8bf4\u660e\uff0c\u8bf7\u53c2\u8003\u5b98\u65b9\u6587\u6863\u4ecb\u7ecd\u3002\u00a0<br\/>\u6ce8\uff1a\u5206\u53f7\uff08;\uff09\u5f00\u5934\u7684\u914d\u7f6e\u8868\u793a\u6ce8\u91ca<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>[unix_http_server]\nfile=\/tmp\/supervisor.sock   ;UNIX socket \u6587\u4ef6\uff0csupervisorctl \u4f1a\u4f7f\u7528\n;chmod=0700                 ;socket\u6587\u4ef6\u7684mode\uff0c\u9ed8\u8ba4\u662f0700\n;chown=nobody:nogroup       ;socket\u6587\u4ef6\u7684owner\uff0c\u683c\u5f0f\uff1auid:gid\n\n;[inet_http_server]         ;HTTP\u670d\u52a1\u5668\uff0c\u63d0\u4f9bweb\u7ba1\u7406\u754c\u9762\n;port=127.0.0.1:9001        ;Web\u7ba1\u7406\u540e\u53f0\u8fd0\u884c\u7684IP\u548c\u7aef\u53e3\uff0c\u5982\u679c\u5f00\u653e\u5230\u516c\u7f51\uff0c\u9700\u8981\u6ce8\u610f\u5b89\u5168\u6027\n;username=user              ;\u767b\u5f55\u7ba1\u7406\u540e\u53f0\u7684\u7528\u6237\u540d\n;password=123               ;\u767b\u5f55\u7ba1\u7406\u540e\u53f0\u7684\u5bc6\u7801\n\n[supervisord]\nlogfile=\/tmp\/supervisord.log ;\u65e5\u5fd7\u6587\u4ef6\uff0c\u9ed8\u8ba4\u662f $CWD\/supervisord.log\nlogfile_maxbytes=50MB        ;\u65e5\u5fd7\u6587\u4ef6\u5927\u5c0f\uff0c\u8d85\u51fa\u4f1arotate\uff0c\u9ed8\u8ba4 50MB\uff0c\u5982\u679c\u8bbe\u62100\uff0c\u8868\u793a\u4e0d\u9650\u5236\u5927\u5c0f\nlogfile_backups=10           ;\u65e5\u5fd7\u6587\u4ef6\u4fdd\u7559\u5907\u4efd\u6570\u91cf\u9ed8\u8ba410\uff0c\u8bbe\u4e3a0\u8868\u793a\u4e0d\u5907\u4efd\nloglevel=info                ;\u65e5\u5fd7\u7ea7\u522b\uff0c\u9ed8\u8ba4info\uff0c\u5176\u5b83: debug,warn,trace\npidfile=\/tmp\/supervisord.pid ;pid \u6587\u4ef6\nnodaemon=false               ;\u662f\u5426\u5728\u524d\u53f0\u542f\u52a8\uff0c\u9ed8\u8ba4\u662ffalse\uff0c\u5373\u4ee5 daemon \u7684\u65b9\u5f0f\u542f\u52a8\nminfds=1024                  ;\u53ef\u4ee5\u6253\u5f00\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684\u6700\u5c0f\u503c\uff0c\u9ed8\u8ba4 1024\nminprocs=200                 ;\u53ef\u4ee5\u6253\u5f00\u7684\u8fdb\u7a0b\u6570\u7684\u6700\u5c0f\u503c\uff0c\u9ed8\u8ba4 200\n\n[supervisorctl]\nserverurl=unix:\/\/\/tmp\/supervisor.sock ;\u901a\u8fc7UNIX socket\u8fde\u63a5supervisord\uff0c\u8def\u5f84\u4e0eunix_http_server\u90e8\u5206\u7684file\u4e00\u81f4\n;serverurl=http:\/\/127.0.0.1:9001 ; \u901a\u8fc7HTTP\u7684\u65b9\u5f0f\u8fde\u63a5supervisord\n\n; [program:xx]\u662f\u88ab\u7ba1\u7406\u7684\u8fdb\u7a0b\u914d\u7f6e\u53c2\u6570\uff0cxx\u662f\u8fdb\u7a0b\u7684\u540d\u79f0\n[program:xx]\ncommand=\/opt\/apache-tomcat-8.0.35\/bin\/catalina.sh run  ; \u7a0b\u5e8f\u542f\u52a8\u547d\u4ee4\nautostart=true       ; \u5728supervisord\u542f\u52a8\u7684\u65f6\u5019\u4e5f\u81ea\u52a8\u542f\u52a8\nstartsecs=10         ; \u542f\u52a810\u79d2\u540e\u6ca1\u6709\u5f02\u5e38\u9000\u51fa\uff0c\u5c31\u8868\u793a\u8fdb\u7a0b\u6b63\u5e38\u542f\u52a8\u4e86\uff0c\u9ed8\u8ba4\u4e3a1\u79d2\nautorestart=true     ; \u7a0b\u5e8f\u9000\u51fa\u540e\u81ea\u52a8\u91cd\u542f,\u53ef\u9009\u503c\uff1a[unexpected,true,false]\uff0c\u9ed8\u8ba4\u4e3aunexpected\uff0c\u8868\u793a\u8fdb\u7a0b\u610f\u5916\u6740\u6b7b\u540e\u624d\u91cd\u542f\nstartretries=3       ; \u542f\u52a8\u5931\u8d25\u81ea\u52a8\u91cd\u8bd5\u6b21\u6570\uff0c\u9ed8\u8ba4\u662f3\nuser=tomcat          ; \u7528\u54ea\u4e2a\u7528\u6237\u542f\u52a8\u8fdb\u7a0b\uff0c\u9ed8\u8ba4\u662froot\npriority=999         ; \u8fdb\u7a0b\u542f\u52a8\u4f18\u5148\u7ea7\uff0c\u9ed8\u8ba4999\uff0c\u503c\u5c0f\u7684\u4f18\u5148\u542f\u52a8\nredirect_stderr=true ; \u628astderr\u91cd\u5b9a\u5411\u5230stdout\uff0c\u9ed8\u8ba4false\nstdout_logfile_maxbytes=20MB  ; stdout \u65e5\u5fd7\u6587\u4ef6\u5927\u5c0f\uff0c\u9ed8\u8ba450MB\nstdout_logfile_backups = 20   ; stdout \u65e5\u5fd7\u6587\u4ef6\u5907\u4efd\u6570\uff0c\u9ed8\u8ba4\u662f10\n; stdout \u65e5\u5fd7\u6587\u4ef6\uff0c\u9700\u8981\u6ce8\u610f\u5f53\u6307\u5b9a\u76ee\u5f55\u4e0d\u5b58\u5728\u65f6\u65e0\u6cd5\u6b63\u5e38\u542f\u52a8\uff0c\u6240\u4ee5\u9700\u8981\u624b\u52a8\u521b\u5efa\u76ee\u5f55\uff08supervisord \u4f1a\u81ea\u52a8\u521b\u5efa\u65e5\u5fd7\u6587\u4ef6\uff09\nstdout_logfile=\/opt\/apache-tomcat-8.0.35\/logs\/catalina.out\nstopasgroup=false     ;\u9ed8\u8ba4\u4e3afalse,\u8fdb\u7a0b\u88ab\u6740\u6b7b\u65f6\uff0c\u662f\u5426\u5411\u8fd9\u4e2a\u8fdb\u7a0b\u7ec4\u53d1\u9001stop\u4fe1\u53f7\uff0c\u5305\u62ec\u5b50\u8fdb\u7a0b\nkillasgroup=false     ;\u9ed8\u8ba4\u4e3afalse\uff0c\u5411\u8fdb\u7a0b\u7ec4\u53d1\u9001kill\u4fe1\u53f7\uff0c\u5305\u62ec\u5b50\u8fdb\u7a0b\n\n;\u5305\u542b\u5176\u5b83\u914d\u7f6e\u6587\u4ef6,\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u4f1a\u65b0\u5efa\u4e00\u4e2a\u76ee\u5f55\u6765\u4e13\u95e8\u5b58\u653e\u670d\u52a1\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u7136\u540e\u5728\u6b64\u6587\u4ef6\u4e2d\u5c06\u5176include\u5305\u542b\u8fdb\u6765\u3002\n[include]\nfiles = relative\/directory\/*.ini    ;\u53ef\u4ee5\u6307\u5b9a\u4e00\u4e2a\u6216\u591a\u4e2a\u4ee5.ini\u7ed3\u675f\u7684\u914d\u7f6e\u6587\u4ef6\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"2\u914d\u7f6e\u7ba1\u7406\u8fdb\u7a0b\">2\u3001\u914d\u7f6e\u7ba1\u7406\u8fdb\u7a0b<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fdb\u7a0b\u7ba1\u7406\u914d\u7f6e\u53c2\u6570\uff0c\u4e0d\u5efa\u8bae\u5168\u90fd\u5199\u5728supervisord.conf\u6587\u4ef6\u4e2d\uff0c\u5e94\u8be5\u6bcf\u4e2a\u8fdb\u7a0b\u5199\u4e00\u4e2a\u914d\u7f6e\u6587\u4ef6\u653e\u5728include\u6307\u5b9a\u7684\u76ee\u5f55\u4e0b\u5305\u542b\u8fdbsupervisord.conf\u6587\u4ef6\u4e2d\u3002\u00a0<br\/>\uff081\uff09\u521b\u5efa\/etc\/supervisor\/config.d\u76ee\u5f55\uff0c\u7528\u4e8e\u5b58\u653e\u8fdb\u7a0b\u7ba1\u7406\u7684\u914d\u7f6e\u6587\u4ef6\u00a0<br\/>\uff082\uff09\u4fee\u6539\/etc\/supervisor\/supervisord.conf\u4e2d\u7684include\u53c2\u6570\uff0c\u5c06\/etc\/supervisor\/conf.d\u76ee\u5f55\u6dfb\u52a0\u5230include\u4e2d<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>[include]\nfiles = \/etc\/supervisor\/config.d\/*.ini<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"3\u670d\u52a1\u914d\u7f6e\u6a21\u677f\">3\u3001\u670d\u52a1\u914d\u7f6e\u6a21\u677f<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>###\u9879\u76ee\u540d\u79f0\uff08program_name\u662f\u552f\u4e00\u4e0d\u53ef\u91cd\u590d\u7684\uff0c\u7528\u6765\u552f\u4e00\u6807\u8bc6\u4e00\u4e2a\u670d\u52a1\uff09\n<\/code><\/pre>\n\n\n<p>[program:program_name]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\n###\u547d\u4ee4\u8981\u80fd\u8fd0\u884c\u5728\u524d\u53f0\uff0c\u5982\u679c\u547d\u4ee4\u52a0\u5165&amp;\u7b26\u53f7\uff0c\u4f8b\u5982&#8221;ping 127.0.0.1 &amp;&#8221;\u547d\u4ee4\u5c31\u4e0d\u80fd\u88absupervisor\u6765\u8fdb\u884c\u76d1\u63a7\u3002\ncommand=php \/home\/wwwroot\/site.webshowu.com\/artisan queue:work redis &#8211;sleep=3 &#8211;tries=3 &#8211;daemon\nautostart=true\nautorestart=true\nuser=root\nnumprocs=3\nredirect_stderr=true\nstdout_logfile=\/home\/wwwlogs\/worker1.log<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>1<\/li><li>2<\/li><li>3<\/li><li>4<\/li><li>5<\/li><li>6<\/li><li>7<\/li><li>8<\/li><li>9<\/li><li>10<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u4e9b\u914d\u7f6e\u9879\u7684\u542b\u4e49\u5df2\u7ecf\u5728\u4e0a\u9762\u7684\u914d\u7f6e\u6587\u4ef6\u8bf4\u660e\u4e2d\u8be6\u7ec6\u8bf4\u660e\u3002\u00a0<br\/>\u4e0b\u9762\u662f\u914d\u7f6eTomcat\u8fdb\u7a0b\u7684\u4e00\u4e2a\u4f8b\u5b50\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>[program:tomcat]\ncommand=\/opt\/apache-tomcat-8.0.35\/bin\/catalina.sh run\nstdout_logfile=\/opt\/apache-tomcat-8.0.35\/logs\/catalina.out\nautostart=true\nautorestart=true\nstartsecs=5\npriority=1\nstopasgroup=true\nkillasgroup=true<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"4web\u7ba1\u7406\u914d\u7f6e\u8bf4\u660e\">4\u3001web\u7ba1\u7406\u914d\u7f6e\u8bf4\u660e<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u7f16\u8f91\u914d\u7f6e\u6587\u4ef6\/etc\/supervisor\/supervisord.conf,\u5728\u6700\u540e\u9762\u52a0\u5982\u4e0b\u914d\u7f6e\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>[inet_http_server]         ; inet (TCP) server disabled by default\nport=0.0.0.0:9001          ; (ip_address:port specifier, *:port for all iface)\nusername=user              ; \u7528\u6237\u540d (default is no username (open server))\npassword=123               ; \u5bc6\u7801 (default is no password (open server))<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6b64\u65f6\u8bbf\u95ee\u672c\u673a\u76849001\u7aef\u53e3\uff0c\u8f93\u5165\u7528\u6237\u540d\u5bc6\u7801\u5373\u53ef\u8fdb\u5165\u6b64\u7ba1\u7406\u9875\u9762<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u4e09\u542f\u52a8\u4e0e\u5173\u95edsupervisor\u548c\u5176\u7ba1\u7406\u7684\u9879\u76ee\">\u4e09\u3001\u542f\u52a8\u4e0e\u5173\u95edsupervisor\u548c\u5176\u7ba1\u7406\u7684\u9879\u76ee<\/h2>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"1\u542f\u52a8supervisor\">1\u3001\u542f\u52a8supervisor<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>##-c\u5236\u5b9a\u8ba9\u5176\u8bfb\u53d6\u7684\u914d\u7f6e\u6587\u4ef6\nsupervisord -c \/etc\/supervisor\/supervisord.conf<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"2\u5173\u95edsupervisor\">2\u3001\u5173\u95edsupervisor<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>supervisorctl shutdown<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"3\u91cd\u65b0\u8f7d\u5165supervisor\u5728\u8fd9\u91cc\u76f8\u5f53\u4e8e\u91cd\u542fsupervisor\u670d\u52a1\u91cc\u9762\u7684\u670d\u52a1\u4e5f\u4f1a\u8ddf\u7740\u91cd\u65b0\u542f\u52a8\">3\u3001\u91cd\u65b0\u8f7d\u5165supervisor\uff0c\u5728\u8fd9\u91cc\u76f8\u5f53\u4e8e\u91cd\u542fsupervisor\u670d\u52a1\uff0c\u91cc\u9762\u7684\u670d\u52a1\u4e5f\u4f1a\u8ddf\u7740\u91cd\u65b0\u542f\u52a8<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>supervisorctl reload<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"4\u6dfb\u52a0\u5220\u9664-\u8981\u7ba1\u7406\u670d\u52a1\">4\u3001\u6dfb\u52a0\/\u5220\u9664 \u8981\u7ba1\u7406\u670d\u52a1<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\uff081\uff09\u6dfb\u52a0\u6216\u5220\u9664\u914d\u7f6e\u6587\u4ef6\u00a0<br\/>\uff082\uff09\u66f4\u65b0<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>supervisorctl update<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"5\u7ba1\u7406supervisor\u4e0b\u7684\u670d\u52a1\">5\u3001\u7ba1\u7406supervisor\u4e0b\u7684\u670d\u52a1<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>###\u542f\u52a8\u670d\u52a1\nsupervisorctl start all\nsupervisorctl start service_name\n###\u5173\u95ed\u670d\u52a1\nsupervisorctl stop all\nsupervisorctl stop service_name\n###\u67e5\u770b\u72b6\u6001\nsupervisorctl status [service_name]\n###\u91cd\u65b0\u542f\u52a8\u6240\u6709\u670d\u52a1\u6216\u8005\u662f\u67d0\u4e2a\u670d\u52a1\nsupervisorctl restart all\nsupervisorctl restart service_name<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u66f4\u591a\u8be6\u7ec6\u4fe1\u606f\u8bf7\u770b<a href=\"http:\/\/supervisord.org\/\" rel=\"noreferrer noopener\" target=\"_blank\">\u5b98\u7f51<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ecb\u7ecd Supervisor\u662f\u4e00\u4e2a\u8fdb\u7a0b\u63a7\u5236\u7cfb\u7edf\u3002 \u5b83\u662f\u4e00\u4e2aC\/S\u7cfb\u7edf,\u670d\u52a1\u7aef\u662fsupervisord\u8fdb\u7a0b\uff0c\u63a7\u5236\u7aef\u4f7f\u7528supervisorctl\u6765\u8fdb\u884c\u63a7\u5236\u542f\u52a8\u8fdb\u7a0b\u3002\u540c\u65f6\u5b83\u4e5f\u63d0\u4f9b\u4e86\u4e00\u4e2aweb\u754c\u9762\uff0c\u6765\u53ef\u4ee5\u4f7f\u6211\u4eec\u65b9\u4fbf\u7684\u8fdb\u884c\u8fdb\u7a0b\u7684\u63a7\u5236\u548c\u67e5\u770b\u65e5\u5fd7\u4fe1\u606f\u3002 supervisord\u548csupervisorctl\u7c7b\u4f3c\u4e8ecentos7\u4e0a\u7684systemd\u548csystemctl\u7684\u5173\u7cfb\uff0c\u4f46\u662f\u53c8\u548csystemd\u4e0d\u540c\uff0c \u4f60\u7684Nginx\uff0cTomcat\uff0cmemcache\uff0cRedis\u2026\u4f1a\u5d29\u4e48\uff1f \u90a3\u4f60\u81ea\u5df1\u5199\u7684\u670d\u52a1\u5668\u76d1\u6d4b\u811a\u672c\u5462\uff1f \u597d\u5427\u3001\u4e0d\u8981\u518d\u7ea0\u7ed3\u4e86\u3001\u4ea4\u7ed9Supervisor\u5427! \u5b83\u4f1a\u5e2e\u4f60\u7ef4\u62a4\u8fd9\u4e9b\u3001\u5373\u4f7f\u5b83\u4eec\u4e0d\u5c0f\u5fc3\u5d29\u4e86\u3001Supervisor\u4f1a\u5e2e\u4f60\u770b\u4f4f\u5b83\u4eec\u3001\u7ef4\u62a4\u5b83\u4eec\uff0c\u91cd\u542f\u5b83\u4eec\u3002 \u4e00\u3001\u5b89\u88c5 \u5b89\u88c5\u73af\u5883\uff1aCentOS7.3 supervisor\u5b89\u88c5\u5b8c\u6210\u540e\u4f1a\u751f\u6210\u4e09\u4e2a\u6267\u884c\u7a0b\u5e8f\uff1asupervisortd\u3001supervisorctl\u3001echo_supervisord_conf\uff0c\u5206\u522b\u662fsupervisor\u7684\u5b88\u62a4\u8fdb\u7a0b\u670d\u52a1\uff08\u7528\u4e8e\u63a5\u6536\u8fdb\u7a0b\u7ba1\u7406\u547d\u4ee4\uff09\u3001\u5ba2\u6237\u7aef\uff08\u7528\u4e8e\u548c\u5b88\u62a4\u8fdb\u7a0b\u901a\u4fe1\uff0c\u53d1\u9001\u7ba1\u7406\u8fdb\u7a0b\u7684\u6307\u4ee4\uff09\u3001\u751f\u6210\u521d\u59cb\u914d\u7f6e\u6587\u4ef6\u7a0b\u5e8f\u3002 \u4e8c\u3001\u914d\u7f6e \u8f93\u51fasupervisor\u914d\u7f6e\uff0c\u53ef\u4ee5\u4f7f\u7528echo_supervisord_conf,\u6211\u4eec\u5c06\u5176\u91cd\u5b9a\u5411\u5230\u6587\u4ef6\u4e2d\uff0c\u7136\u540e\u5c31\u53ef\u4ee5\u4fee\u6539\u5176\u914d\u7f6e\u9879\u4e86\u3002\u00a0\u8fd0\u884csupervisord\u670d\u52a1\u7684\u65f6\u5019\uff0c\u9700\u8981\u6307\u5b9asupervisor\u914d\u7f6e\u6587\u4ef6\uff0c\u5982\u679c\u6ca1\u6709\u663e\u793a\u6307\u5b9a\uff0c\u9ed8\u8ba4\u5728\u4ee5\u4e0b\u76ee\u5f55\u67e5\u627e\uff1a \u6211\u4eec\u5c06\u5176\u91cd\u5b9a\u5411\u5230\/etc\/\u76ee\u5f55\u4e0b\u9762 1\u3001\u914d\u7f6e\u6587\u4ef6\u53c2\u6570\u8bf4\u660e supervisor\u7684\u914d\u7f6e\u53c2\u6570\u8f83\u591a\uff0c\u4e0b\u9762\u4ecb\u7ecd\u4e00\u4e0b\u5e38\u7528\u7684\u53c2\u6570\u914d\u7f6e\uff0c\u8be6\u7ec6\u7684\u914d\u7f6e\u53ca\u8bf4\u660e\uff0c\u8bf7\u53c2\u8003\u5b98\u65b9\u6587\u6863\u4ecb\u7ecd\u3002\u00a0\u6ce8\uff1a\u5206\u53f7\uff08;\uff09\u5f00\u5934\u7684\u914d\u7f6e\u8868\u793a\u6ce8\u91ca 2\u3001\u914d\u7f6e\u7ba1\u7406\u8fdb\u7a0b \u8fdb\u7a0b\u7ba1\u7406\u914d\u7f6e\u53c2\u6570\uff0c\u4e0d\u5efa\u8bae\u5168\u90fd\u5199\u5728supervisord.conf\u6587\u4ef6\u4e2d\uff0c\u5e94\u8be5\u6bcf\u4e2a\u8fdb\u7a0b\u5199\u4e00\u4e2a\u914d\u7f6e\u6587\u4ef6\u653e\u5728include\u6307\u5b9a\u7684\u76ee\u5f55\u4e0b\u5305\u542b\u8fdbsupervisord.conf\u6587\u4ef6\u4e2d\u3002\u00a0\uff081\uff09\u521b\u5efa\/etc\/supervisor\/config.d\u76ee\u5f55\uff0c\u7528\u4e8e\u5b58\u653e\u8fdb\u7a0b\u7ba1\u7406\u7684\u914d\u7f6e\u6587\u4ef6\u00a0\uff082\uff09\u4fee\u6539\/etc\/supervisor\/supervisord.conf\u4e2d\u7684include\u53c2\u6570\uff0c\u5c06\/etc\/supervisor\/conf.d\u76ee\u5f55\u6dfb\u52a0\u5230include\u4e2d 3\u3001\u670d\u52a1\u914d\u7f6e\u6a21\u677f ###\u547d\u4ee4\u8981\u80fd\u8fd0\u884c\u5728\u524d\u53f0\uff0c\u5982\u679c\u547d\u4ee4\u52a0\u5165&amp;\u7b26\u53f7\uff0c\u4f8b\u5982&#8221;ping [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[1],"tags":[],"class_list":["post-996","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts\/996","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=996"}],"version-history":[{"count":0,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts\/996\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=996"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=996"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=996"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}