{"id":2944,"date":"2019-03-10T11:33:19","date_gmt":"2019-03-10T03:33:19","guid":{"rendered":"https:\/\/damogame.cn:15443\/wordpress\/?p=2944"},"modified":"2019-03-10T11:33:19","modified_gmt":"2019-03-10T03:33:19","slug":"%e8%bf%9b%e7%a8%8b%e7%ae%a1%e7%90%86supervisor%e7%9a%84%e7%ae%80%e5%8d%95%e8%af%b4%e6%98%8e","status":"publish","type":"post","link":"https:\/\/i007.cc\/wordpress\/archives\/2944","title":{"rendered":"\u8fdb\u7a0b\u7ba1\u7406supervisor\u7684\u7b80\u5355\u8bf4\u660e"},"content":{"rendered":"<div id=\"cnblogs_post_body\" class=\"blogpost-body\">\n<h2>\u80cc\u666f\uff1a<\/h2>\n<p>\u9879\u76ee\u4e2d\u9047\u5230\u6709\u4e9b\u811a\u672c\u9700\u8981\u901a\u8fc7\u540e\u53f0\u8fdb\u7a0b\u8fd0\u884c\uff0c\u4fdd\u8bc1\u4e0d\u88ab\u5f02\u5e38\u4e2d\u65ad\uff0c\u4e4b\u524d\u90fd\u662f\u901a\u8fc7nohup\u3001&amp;\u3001screen\u6765\u5b9e\u73b0\uff0c\u5e26\u7740\u80fd\u5426\u505a\u4e00\u4e2astart\/stop\/restart\/reload\u7684\u670d\u52a1\u542f\u52a8\u7684\u60f3\u6cd5\u627e\u5230\u91cc<a href=\"http:\/\/supervisord.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">Supervisor<\/a>\u3002\u5173\u4e8e<a href=\"http:\/\/supervisord.org\/introduction.html\" target=\"_blank\" rel=\"noopener noreferrer\">supervisor\u7684\u4ecb\u7ecd<\/a>\u5728\u7f51\u4e0a\u5927\u81f4\u641c\u7d22\u603b\u7ed3\u5982\u4e0b\uff1a<\/p>\n<p>Supervisor\u662f\u7528Python\u5f00\u53d1\u7684\u4e00\u5957\u901a\u7528\u7684\u8fdb\u7a0b\u7ba1\u7406\u7a0b\u5e8f\uff0c\u80fd\u5c06\u4e00\u4e2a\u666e\u901a\u7684\u547d\u4ee4\u884c\u8fdb\u7a0b\u53d8\u4e3a\u540e\u53f0daemon\uff0c\u5e76\u76d1\u63a7\u8fdb\u7a0b\u72b6\u6001\uff0c\u5f02\u5e38\u9000\u51fa\u65f6\u80fd\u81ea\u52a8\u91cd\u542f\u3002\u5b83\u662f\u901a\u8fc7fork\/exec\u7684\u65b9\u5f0f\u628a\u8fd9\u4e9b\u88ab\u7ba1\u7406\u7684\u8fdb\u7a0b\u5f53\u4f5csupervisor\u7684\u5b50\u8fdb\u7a0b\u6765\u542f\u52a8\uff0c\u8fd9\u6837\u53ea\u8981\u5728supervisor\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u628a\u8981\u7ba1\u7406\u7684\u8fdb\u7a0b\u7684\u53ef\u6267\u884c\u6587\u4ef6\u7684\u8def\u5f84\u5199\u8fdb\u53bb\u5373\u53ef\u3002\u4e5f\u5b9e\u73b0\u5f53\u5b50\u8fdb\u7a0b\u6302\u6389\u7684\u65f6\u5019\uff0c\u7236\u8fdb\u7a0b\u53ef\u4ee5\u51c6\u786e\u83b7\u53d6\u5b50\u8fdb\u7a0b\u6302\u6389\u7684\u4fe1\u606f\u7684\uff0c\u53ef\u4ee5\u9009\u62e9\u662f\u5426\u81ea\u5df1\u542f\u52a8\u548c\u62a5\u8b66\u3002supervisor\u8fd8\u63d0\u4f9b\u4e86\u4e00\u4e2a\u529f\u80fd\uff0c\u53ef\u4ee5\u4e3asupervisord\u6216\u8005\u6bcf\u4e2a\u5b50\u8fdb\u7a0b\uff0c\u8bbe\u7f6e\u4e00\u4e2a\u975eroot\u7684user\uff0c\u8fd9\u4e2auser\u5c31\u53ef\u4ee5\u7ba1\u7406\u5b83\u5bf9\u5e94\u7684\u8fdb\u7a0b\u3002<\/p>\n<h2>\u8bf4\u660e\uff1a<\/h2>\n<p><strong><a href=\"http:\/\/supervisord.org\/installing.html\" target=\"_blank\" rel=\"noopener noreferrer\">1\uff0c\u5b89\u88c5<\/a><\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">1\uff1aeasy_install \u5b89\u88c5\uff1a\r\neasy_install supervisor\r\n\r\n2\uff1apip \u5b89\u88c5\uff1a\r\npip install supervisor\r\n\r\n3\uff1aDebian \/ Ubuntu\u53ef\u4ee5\u76f4\u63a5\u901a\u8fc7apt\u5b89\u88c5\uff1a\r\napt-get install supervisor<\/pre>\n<p><strong><a href=\"http:\/\/supervisord.org\/configuration.html\" target=\"_blank\" rel=\"noopener noreferrer\">2\uff0c\u914d\u7f6e\u6587\u4ef6<\/a><\/strong><\/p>\n<p><strong>1\uff09<\/strong>\u901a\u8fc7apt-get install\u5b89\u88c5\u540e\uff0csupervisor\u7684\u914d\u7f6e\u6587\u4ef6\u5728\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">\/etc\/supervisor\/supervisord.conf<\/pre>\n<p>supervisor\u7684\u914d\u7f6e\u6587\u4ef6\u9ed8\u8ba4\u662f\u4e0d\u5168\u7684\uff0c\u4e0d\u8fc7\u5728\u5927\u90e8\u5206\u9ed8\u8ba4\u7684\u60c5\u51b5\u4e0b\uff0c\u4e0a\u9762\u8bf4\u7684\u57fa\u672c\u529f\u80fd\u5df2\u7ecf\u6ee1\u8db3\u3002\u800c\u5176\u7ba1\u7406\u7684<a href=\"http:\/\/supervisord.org\/subprocess.html\" target=\"_blank\" rel=\"noopener noreferrer\">\u5b50\u8fdb\u7a0b\u914d\u7f6e<\/a>\u6587\u4ef6\u5728\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">\/etc\/supervisor\/conf.d\/*.conf<\/pre>\n<p>\u7136\u540e\uff0c\u5f00\u59cb\u7ed9\u81ea\u5df1\u9700\u8981\u7684\u811a\u672c\u7a0b\u5e8f\u7f16\u5199\u4e00\u4e2a\u5b50\u8fdb\u7a0b\u914d\u7f6e\u6587\u4ef6\uff0c\u8ba9supervisor\u6765\u7ba1\u7406\u5b83\uff0c\u653e\u5728\/etc\/supervisor\/conf.d\/\u76ee\u5f55\u4e0b\uff0c\u4ee5.conf\u4f5c\u4e3a\u6269\u5c55\u540d\uff08\u6bcf\u4e2a\u8fdb\u7a0b\u7684\u914d\u7f6e\u6587\u4ef6\u90fd\u53ef\u4ee5\u5355\u72ec\u5206\u62c6\u4e5f\u53ef\u4ee5\u628a\u76f8\u5173\u7684\u811a\u672c\u653e\u4e00\u8d77\uff09\u3002\u5982\u4efb\u610f\u5b9a\u4e49\u4e00\u4e2a\u548c\u811a\u672c\u76f8\u5173\u7684\u9879\u76ee\u540d\u79f0\u7684\u9009\u9879\u7ec4\uff08\/etc\/supervisor\/conf.d\/test.conf\uff09\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">#\u9879\u76ee\u540d[program:blog]\r\n#\u811a\u672c\u76ee\u5f55\r\ndirectory=\/opt\/bin\r\n#\u811a\u672c\u6267\u884c\u547d\u4ee4\r\ncommand=\/usr\/bin\/python \/opt\/bin\/test.py\r\n#supervisor\u542f\u52a8\u7684\u65f6\u5019\u662f\u5426\u968f\u7740\u540c\u65f6\u542f\u52a8\uff0c\u9ed8\u8ba4True\r\nautostart=true\r\n#\u5f53\u7a0b\u5e8fexit\u7684\u65f6\u5019\uff0c\u8fd9\u4e2aprogram\u4e0d\u4f1a\u81ea\u52a8\u91cd\u542f,\u9ed8\u8ba4unexpected\r\n#\u8bbe\u7f6e\u5b50\u8fdb\u7a0b\u6302\u6389\u540e\u81ea\u52a8\u91cd\u542f\u7684\u60c5\u51b5\uff0c\u6709\u4e09\u4e2a\u9009\u9879\uff0cfalse,unexpected\u548ctrue\u3002\u5982\u679c\u4e3afalse\u7684\u65f6\u5019\uff0c\u65e0\u8bba\u4ec0\u4e48\u60c5\u51b5\u4e0b\uff0c\u90fd\u4e0d\u4f1a\u88ab\u91cd\u65b0\u542f\u52a8\uff0c\u5982\u679c\u4e3aunexpected\uff0c\u53ea\u6709\u5f53\u8fdb\u7a0b\u7684\u9000\u51fa\u7801\u4e0d\u5728\u4e0b\u9762\u7684exitcodes\u91cc\u9762\u5b9a\u4e49\u7684\r\nautorestart=false\r\n#\u8fd9\u4e2a\u9009\u9879\u662f\u5b50\u8fdb\u7a0b\u542f\u52a8\u591a\u5c11\u79d2\u4e4b\u540e\uff0c\u6b64\u65f6\u72b6\u6001\u5982\u679c\u662frunning\uff0c\u5219\u6211\u4eec\u8ba4\u4e3a\u542f\u52a8\u6210\u529f\u4e86\u3002\u9ed8\u8ba4\u503c\u4e3a1\r\nstartsecs=1\r\n#\u65e5\u5fd7\u8f93\u51fa \r\nstderr_logfile=\/tmp\/blog_stderr.log \r\nstdout_logfile=\/tmp\/blog_stdout.log \r\n#\u811a\u672c\u8fd0\u884c\u7684\u7528\u6237\u8eab\u4efd \r\nuser = zhoujy \r\n#\u628a stderr \u91cd\u5b9a\u5411\u5230 stdout\uff0c\u9ed8\u8ba4 false\r\nredirect_stderr = true\r\n#stdout \u65e5\u5fd7\u6587\u4ef6\u5927\u5c0f\uff0c\u9ed8\u8ba4 50MB\r\nstdout_logfile_maxbytes = 20M\r\n#stdout \u65e5\u5fd7\u6587\u4ef6\u5907\u4efd\u6570\r\nstdout_logfile_backups = 20\r\n\r\n\r\n[program:zhoujy] #\u8bf4\u660e\u540c\u4e0a\r\ndirectory=\/opt\/bin \r\ncommand=\/usr\/bin\/python \/opt\/bin\/zhoujy.py \r\nautostart=true \r\nautorestart=false \r\nstderr_logfile=\/tmp\/zhoujy_stderr.log \r\nstdout_logfile=\/tmp\/zhoujy_stdout.log \r\n#user = zhoujy<\/pre>\n<p><strong>2\uff09<\/strong>\u901a\u8fc7easy_install\u5b89\u88c5\u540e\uff0c\u914d\u7f6e\u6587\u4ef6\u4e0d\u5b58\u5728\uff0c\u9700\u8981\u81ea\u5df1\u5bfc\u5165\u3002<\/p>\n<p>\u2460\uff1a\u8fd0\u884c<a href=\"http:\/\/supervisord.org\/installing.html\" target=\"_blank\" rel=\"noopener noreferrer\">echo_supervisord_conf<\/a>\u6253\u5370\u51fa\u4e00\u4e2a\u914d\u7f6e\u6587\u4ef6\u7684\u6837\u672c\uff0c\u6837\u672c\u8bf4\u660e\u53ef\u4ee5\u770b<a href=\"http:\/\/lixcto.blog.51cto.com\/4834175\/1539136\" target=\"_blank\" rel=\"noopener noreferrer\">supervisor(\u4e00)\u57fa\u7840\u7bc7<\/a>\u7684\u8be6\u7ec6\u8bf4\u660e\uff0c\u8981\u662f\u8bbe\u7f6e\u6837\u672c\u4e3a\u4e00\u4e2a\u914d\u7f6e\u6587\u4ef6\u5219\uff1a<\/p>\n<div class=\"cnblogs_code\">\n<pre>1\uff1a\u8fd0\u884c echo_supervisord_conf\uff0c\u67e5\u770b\u914d\u7f6e\u6837\u672c\uff1a<\/pre>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">echo_supervisord_conf<\/pre>\n<pre>2\uff1a\u521b\u5efa\u914d\u7f6e\u6587\u4ef6\uff1a<\/pre>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">echo_supervisord_conf &gt; \/etc\/supervisord.conf<\/pre>\n<\/div>\n<p>\u2461\uff1a\u914d\u7f6e\u5b50\u8fdb\u7a0b\u914d\u7f6e\u6587\u4ef6\uff0c\u53ef\u4ee5\u76f4\u63a5\u5728supervisor\u4e2d\u7684<strong><span class=\"s1\">;[program:theprogramname]<\/span><\/strong><span class=\"s1\">\u91cc\u8bbe\u7f6e\u3002<\/span><\/p>\n<p><span class=\"s1\">\u8be6\u7ec6\u7684<a href=\"http:\/\/supervisord.org\/subprocess.html\" target=\"_blank\" rel=\"noopener noreferrer\">\u5b50\u8fdb\u7a0b\u914d\u7f6e<\/a>\u6587\u4ef6\uff1a<\/span><\/p>\n<p><span class=\"s1\">\u6837\u672c\uff1a<\/span><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">;[program:theprogramname]\r\n;command=\/bin\/cat              ; the program (relative uses PATH, can take args)\r\n;process_name=%(program_name)s ; process_name expr (default %(program_name)s)\r\n;numprocs=1                    ; number of processes copies to start (def 1)\r\n;directory=\/tmp                ; directory to cwd to before exec (def no cwd)\r\n;umask=022                     ; umask for process (default None)\r\n;priority=999                  ; the relative start priority (default 999)\r\n;autostart=true                ; start at supervisord start (default: true)\r\n;startsecs=1                   ; # of secs prog must stay up to be running (def. 1)\r\n;startretries=3                ; max # of serial start failures when starting (default 3)\r\n;autorestart=unexpected        ; when to restart if exited after running (def: unexpected)\r\n;exitcodes=0,2                 ; 'expected' exit codes used with autorestart (default 0,2)\r\n;stopsignal=QUIT               ; signal used to kill process (default TERM)\r\n;stopwaitsecs=10               ; max num secs to wait b4 SIGKILL (default 10)\r\n;stopasgroup=false             ; send stop signal to the UNIX process group (default false)\r\n;killasgroup=false             ; SIGKILL the UNIX process group (def false)\r\n;user=chrism                   ; setuid to this UNIX account to run the program\r\n;redirect_stderr=true          ; redirect proc stderr to stdout (default false)\r\n;stdout_logfile=\/a\/path        ; stdout log path, NONE for none; default AUTO\r\n;stdout_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)\r\n;stdout_logfile_backups=10     ; # of stdout logfile backups (default 10)\r\n;stdout_capture_maxbytes=1MB   ; number of bytes in 'capturemode' (default 0)\r\n;stdout_events_enabled=false   ; emit events on stdout writes (default false)\r\n;stderr_logfile=\/a\/path        ; stderr log path, NONE for none; default AUTO\r\n;stderr_logfile_maxbytes=1MB   ; max # logfile bytes b4 rotation (default 50MB)\r\n;stderr_logfile_backups=10     ; # of stderr logfile backups (default 10)\r\n;stderr_capture_maxbytes=1MB   ; number of bytes in 'capturemode' (default 0)\r\n;stderr_events_enabled=false   ; emit events on stderr writes (default false)\r\n;environment=A=\"1\",B=\"2\"       ; process environment additions (def no adds)\r\n;serverurl=AUTO                ; override serverurl computation (childutils)<\/pre>\n<p>\u8bf4\u660e\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">;[program:theprogramname]      ;\u8fd9\u4e2a\u5c31\u662f\u54b1\u4eec\u8981\u7ba1\u7406\u7684\u5b50\u8fdb\u7a0b\u4e86\uff0c\":\"\u540e\u9762\u7684\u662f\u540d\u5b57\uff0c\u6700\u597d\u522b\u4e71\u5199\u548c\u5b9e\u9645\u8fdb\u7a0b\r\n                                \u6709\u70b9\u5173\u8054\u6700\u597d\u3002\u8fd9\u6837\u7684program\u6211\u4eec\u53ef\u4ee5\u8bbe\u7f6e\u4e00\u4e2a\u6216\u591a\u4e2a\uff0c\u4e00\u4e2aprogram\u5c31\u662f\r\n                                \u8981\u88ab\u7ba1\u7406\u7684\u4e00\u4e2a\u8fdb\u7a0b\r\n;command=\/bin\/cat              ; \u8fd9\u4e2a\u5c31\u662f\u6211\u4eec\u7684\u8981\u542f\u52a8\u8fdb\u7a0b\u7684\u547d\u4ee4\u8def\u5f84\u4e86\uff0c\u53ef\u4ee5\u5e26\u53c2\u6570\r\n                                \u4f8b\u5b50\uff1a\/home\/test.py -a 'hehe'\r\n                                \u6709\u4e00\u70b9\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u6211\u4eec\u7684command\u53ea\u80fd\u662f\u90a3\u79cd\u5728\u7ec8\u7aef\u8fd0\u884c\u7684\u8fdb\u7a0b\uff0c\u4e0d\u80fd\u662f\r\n                                \u5b88\u62a4\u8fdb\u7a0b\u3002\u8fd9\u4e2a\u60f3\u60f3\u4e5f\u77e5\u9053\u4e86\uff0c\u6bd4\u5982\u8bf4command=service httpd start\u3002\r\n                                httpd\u8fd9\u4e2a\u8fdb\u7a0b\u88ablinux\u7684service\u7ba1\u7406\u4e86\uff0c\u6211\u4eec\u7684supervisor\u518d\u53bb\u542f\u52a8\u8fd9\u4e2a\u547d\u4ee4\r\n                                \u8fd9\u5df2\u7ecf\u4e0d\u662f\u4e25\u683c\u610f\u4e49\u7684\u5b50\u8fdb\u7a0b\u4e86\u3002\r\n                                \u8fd9\u4e2a\u662f\u4e2a\u5fc5\u987b\u8bbe\u7f6e\u7684\u9879\r\n;process_name=%(program_name)s ; \u8fd9\u4e2a\u662f\u8fdb\u7a0b\u540d\uff0c\u5982\u679c\u6211\u4eec\u4e0b\u9762\u7684numprocs\u53c2\u6570\u4e3a1\u7684\u8bdd\uff0c\u5c31\u4e0d\u7528\u7ba1\u8fd9\u4e2a\u53c2\u6570\r\n                                 \u4e86\uff0c\u5b83\u9ed8\u8ba4\u503c%(program_name)s\u4e5f\u5c31\u662f\u4e0a\u9762\u7684\u90a3\u4e2aprogram\u5192\u53f7\u540e\u9762\u7684\u540d\u5b57\uff0c\r\n                                 \u4f46\u662f\u5982\u679cnumprocs\u4e3a\u591a\u4e2a\u7684\u8bdd\uff0c\u90a3\u5c31\u4e0d\u80fd\u8fd9\u4e48\u5e72\u4e86\u3002\u60f3\u60f3\u4e5f\u77e5\u9053\uff0c\u4e0d\u53ef\u80fd\u6bcf\u4e2a\r\n                                 \u8fdb\u7a0b\u90fd\u7528\u540c\u4e00\u4e2a\u8fdb\u7a0b\u540d\u5427\u3002\r\n\r\n                                \r\n;numprocs=1                    ; \u542f\u52a8\u8fdb\u7a0b\u7684\u6570\u76ee\u3002\u5f53\u4e0d\u4e3a1\u65f6\uff0c\u5c31\u662f\u8fdb\u7a0b\u6c60\u7684\u6982\u5ff5\uff0c\u6ce8\u610fprocess_name\u7684\u8bbe\u7f6e\r\n                                 \u9ed8\u8ba4\u4e3a1    \u3002\u3002\u975e\u5fc5\u987b\u8bbe\u7f6e\r\n;directory=\/tmp                ; \u8fdb\u7a0b\u8fd0\u884c\u524d\uff0c\u4f1a\u524d\u5207\u6362\u5230\u8fd9\u4e2a\u76ee\u5f55\r\n                                 \u9ed8\u8ba4\u4e0d\u8bbe\u7f6e\u3002\u3002\u3002\u975e\u5fc5\u987b\u8bbe\u7f6e\r\n;umask=022                     ; \u8fdb\u7a0b\u63a9\u7801\uff0c\u9ed8\u8ba4none\uff0c\u975e\u5fc5\u987b\r\n;priority=999                  ; \u5b50\u8fdb\u7a0b\u542f\u52a8\u5173\u95ed\u4f18\u5148\u7ea7\uff0c\u4f18\u5148\u7ea7\u4f4e\u7684\uff0c\u6700\u5148\u542f\u52a8\uff0c\u5173\u95ed\u7684\u65f6\u5019\u6700\u540e\u5173\u95ed\r\n                                 \u9ed8\u8ba4\u503c\u4e3a999 \u3002\u3002\u975e\u5fc5\u987b\u8bbe\u7f6e\r\n;autostart=true                ; \u5982\u679c\u662ftrue\u7684\u8bdd\uff0c\u5b50\u8fdb\u7a0b\u5c06\u5728supervisord\u542f\u52a8\u540e\u88ab\u81ea\u52a8\u542f\u52a8\r\n                                 \u9ed8\u8ba4\u5c31\u662ftrue   \u3002\u3002\u975e\u5fc5\u987b\u8bbe\u7f6e\r\n;autorestart=unexpected        ; \u8fd9\u4e2a\u662f\u8bbe\u7f6e\u5b50\u8fdb\u7a0b\u6302\u6389\u540e\u81ea\u52a8\u91cd\u542f\u7684\u60c5\u51b5\uff0c\u6709\u4e09\u4e2a\u9009\u9879\uff0cfalse,unexpected\r\n                                 \u548ctrue\u3002\u5982\u679c\u4e3afalse\u7684\u65f6\u5019\uff0c\u65e0\u8bba\u4ec0\u4e48\u60c5\u51b5\u4e0b\uff0c\u90fd\u4e0d\u4f1a\u88ab\u91cd\u65b0\u542f\u52a8\uff0c\r\n                                 \u5982\u679c\u4e3aunexpected\uff0c\u53ea\u6709\u5f53\u8fdb\u7a0b\u7684\u9000\u51fa\u7801\u4e0d\u5728\u4e0b\u9762\u7684exitcodes\u91cc\u9762\u5b9a\u4e49\u7684\u9000 \r\n                                 \u51fa\u7801\u7684\u65f6\u5019\uff0c\u624d\u4f1a\u88ab\u81ea\u52a8\u91cd\u542f\u3002\u5f53\u4e3atrue\u7684\u65f6\u5019\uff0c\u53ea\u8981\u5b50\u8fdb\u7a0b\u6302\u6389\uff0c\u5c06\u4f1a\u88ab\u65e0\r\n                                 \u6761\u4ef6\u7684\u91cd\u542f\r\n;startsecs=1                   ; \u8fd9\u4e2a\u9009\u9879\u662f\u5b50\u8fdb\u7a0b\u542f\u52a8\u591a\u5c11\u79d2\u4e4b\u540e\uff0c\u6b64\u65f6\u72b6\u6001\u5982\u679c\u662frunning\uff0c\u5219\u6211\u4eec\u8ba4\u4e3a\u542f\r\n                                 \u52a8\u6210\u529f\u4e86\r\n                                 \u9ed8\u8ba4\u503c\u4e3a1 \u3002\u3002\u975e\u5fc5\u987b\u8bbe\u7f6e\r\n;startretries=3                ; \u5f53\u8fdb\u7a0b\u542f\u52a8\u5931\u8d25\u540e\uff0c\u6700\u5927\u5c1d\u8bd5\u542f\u52a8\u7684\u6b21\u6570\u3002\u3002\u5f53\u8d85\u8fc73\u6b21\u540e\uff0csupervisor\u5c06\u628a\r\n                                 \u6b64\u8fdb\u7a0b\u7684\u72b6\u6001\u7f6e\u4e3aFAIL\r\n                                 \u9ed8\u8ba4\u503c\u4e3a3 \u3002\u3002\u975e\u5fc5\u987b\u8bbe\u7f6e\r\n;exitcodes=0,2                 ; \u6ce8\u610f\u548c\u4e0a\u9762\u7684\u7684autorestart=unexpected\u5bf9\u5e94\u3002\u3002exitcodes\u91cc\u9762\u7684\u5b9a\u4e49\u7684\r\n                                 \u9000\u51fa\u7801\u662fexpected\u7684\u3002\r\n;stopsignal=QUIT               ; \u8fdb\u7a0b\u505c\u6b62\u4fe1\u53f7\uff0c\u53ef\u4ee5\u4e3aTERM, HUP, INT, QUIT, KILL, USR1, or USR2\u7b49\u4fe1\u53f7\r\n                                  \u9ed8\u8ba4\u4e3aTERM \u3002\u3002\u5f53\u7528\u8bbe\u5b9a\u7684\u4fe1\u53f7\u53bb\u5e72\u6389\u8fdb\u7a0b\uff0c\u9000\u51fa\u7801\u4f1a\u88ab\u8ba4\u4e3a\u662fexpected\r\n                                  \u975e\u5fc5\u987b\u8bbe\u7f6e\r\n;stopwaitsecs=10               ; \u8fd9\u4e2a\u662f\u5f53\u6211\u4eec\u5411\u5b50\u8fdb\u7a0b\u53d1\u9001stopsignal\u4fe1\u53f7\u540e\uff0c\u5230\u7cfb\u7edf\u8fd4\u56de\u4fe1\u606f\r\n                                 \u7ed9supervisord\uff0c\u6240\u7b49\u5f85\u7684\u6700\u5927\u65f6\u95f4\u3002 \u8d85\u8fc7\u8fd9\u4e2a\u65f6\u95f4\uff0csupervisord\u4f1a\u5411\u8be5\r\n                                 \u5b50\u8fdb\u7a0b\u53d1\u9001\u4e00\u4e2a\u5f3a\u5236kill\u7684\u4fe1\u53f7\u3002\r\n                                 \u9ed8\u8ba4\u4e3a10\u79d2\u3002\u3002\u975e\u5fc5\u987b\u8bbe\u7f6e\r\n;stopasgroup=false             ; \u8fd9\u4e2a\u4e1c\u897f\u4e3b\u8981\u7528\u4e8e\uff0csupervisord\u7ba1\u7406\u7684\u5b50\u8fdb\u7a0b\uff0c\u8fd9\u4e2a\u5b50\u8fdb\u7a0b\u672c\u8eab\u8fd8\u6709\r\n                                 \u5b50\u8fdb\u7a0b\u3002\u90a3\u4e48\u6211\u4eec\u5982\u679c\u4ec5\u4ec5\u5e72\u6389supervisord\u7684\u5b50\u8fdb\u7a0b\u7684\u8bdd\uff0c\u5b50\u8fdb\u7a0b\u7684\u5b50\u8fdb\u7a0b\r\n                                 \u6709\u53ef\u80fd\u4f1a\u53d8\u6210\u5b64\u513f\u8fdb\u7a0b\u3002\u6240\u4ee5\u54b1\u4eec\u53ef\u4ee5\u8bbe\u7f6e\u53ef\u4e2a\u9009\u9879\uff0c\u628a\u6574\u4e2a\u8be5\u5b50\u8fdb\u7a0b\u7684\r\n                                 \u6574\u4e2a\u8fdb\u7a0b\u7ec4\u90fd\u5e72\u6389\u3002 \u8bbe\u7f6e\u4e3atrue\u7684\u8bdd\uff0c\u4e00\u822ckillasgroup\u4e5f\u4f1a\u88ab\u8bbe\u7f6e\u4e3atrue\u3002\r\n                                 \u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u8be5\u9009\u9879\u53d1\u9001\u7684\u662fstop\u4fe1\u53f7\r\n                                 \u9ed8\u8ba4\u4e3afalse\u3002\u3002\u975e\u5fc5\u987b\u8bbe\u7f6e\u3002\u3002\r\n;killasgroup=false             ; \u8fd9\u4e2a\u548c\u4e0a\u9762\u7684stopasgroup\u7c7b\u4f3c\uff0c\u4e0d\u8fc7\u53d1\u9001\u7684\u662fkill\u4fe1\u53f7\r\n;user=chrism                   ; \u5982\u679csupervisord\u662froot\u542f\u52a8\uff0c\u6211\u4eec\u5728\u8fd9\u91cc\u8bbe\u7f6e\u8fd9\u4e2a\u975eroot\u7528\u6237\uff0c\u53ef\u4ee5\u7528\u6765\r\n                                 \u7ba1\u7406\u8be5program\r\n                                 \u9ed8\u8ba4\u4e0d\u8bbe\u7f6e\u3002\u3002\u3002\u975e\u5fc5\u987b\u8bbe\u7f6e\u9879\r\n;redirect_stderr=true          ; \u5982\u679c\u4e3atrue\uff0c\u5219stderr\u7684\u65e5\u5fd7\u4f1a\u88ab\u5199\u5165stdout\u65e5\u5fd7\u6587\u4ef6\u4e2d\r\n                                 \u9ed8\u8ba4\u4e3afalse\uff0c\u975e\u5fc5\u987b\u8bbe\u7f6e\r\n;stdout_logfile=\/a\/path        ; \u5b50\u8fdb\u7a0b\u7684stdout\u7684\u65e5\u5fd7\u8def\u5f84\uff0c\u53ef\u4ee5\u6307\u5b9a\u8def\u5f84\uff0cAUTO\uff0cnone\u7b49\u4e09\u4e2a\u9009\u9879\u3002\r\n                                 \u8bbe\u7f6e\u4e3anone\u7684\u8bdd\uff0c\u5c06\u6ca1\u6709\u65e5\u5fd7\u4ea7\u751f\u3002\u8bbe\u7f6e\u4e3aAUTO\u7684\u8bdd\uff0c\u5c06\u968f\u673a\u627e\u4e00\u4e2a\u5730\u65b9\r\n                                 \u751f\u6210\u65e5\u5fd7\u6587\u4ef6\uff0c\u800c\u4e14\u5f53supervisord\u91cd\u65b0\u542f\u52a8\u7684\u65f6\u5019\uff0c\u4ee5\u524d\u7684\u65e5\u5fd7\u6587\u4ef6\u4f1a\u88ab\r\n                                 \u6e05\u7a7a\u3002\u5f53 redirect_stderr=true\u7684\u65f6\u5019\uff0csterr\u4e5f\u4f1a\u5199\u8fdb\u8fd9\u4e2a\u65e5\u5fd7\u6587\u4ef6\r\n;stdout_logfile_maxbytes=1MB   ; \u65e5\u5fd7\u6587\u4ef6\u6700\u5927\u5927\u5c0f\uff0c\u548c[supervisord]\u4e2d\u5b9a\u4e49\u7684\u4e00\u6837\u3002\u9ed8\u8ba4\u4e3a50\r\n;stdout_logfile_backups=10     ; \u548c[supervisord]\u5b9a\u4e49\u7684\u4e00\u6837\u3002\u9ed8\u8ba410\r\n;stdout_capture_maxbytes=1MB   ; \u8fd9\u4e2a\u4e1c\u897f\u662f\u8bbe\u5b9acapture\u7ba1\u9053\u7684\u5927\u5c0f\uff0c\u5f53\u503c\u4e0d\u4e3a0\u7684\u65f6\u5019\uff0c\u5b50\u8fdb\u7a0b\u53ef\u4ee5\u4ecestdout\r\n                                 \u53d1\u9001\u4fe1\u606f\uff0c\u800csupervisor\u53ef\u4ee5\u6839\u636e\u4fe1\u606f\uff0c\u53d1\u9001\u76f8\u5e94\u7684event\u3002\r\n                                 \u9ed8\u8ba4\u4e3a0\uff0c\u4e3a0\u7684\u65f6\u5019\u8868\u8fbe\u5173\u95ed\u7ba1\u9053\u3002\u3002\u3002\u975e\u5fc5\u987b\u9879\r\n;stdout_events_enabled=false   ; \u5f53\u8bbe\u7f6e\u4e3ature\u7684\u65f6\u5019\uff0c\u5f53\u5b50\u8fdb\u7a0b\u7531stdout\u5411\u6587\u4ef6\u63cf\u8ff0\u7b26\u4e2d\u5199\u65e5\u5fd7\u7684\u65f6\u5019\uff0c\u5c06\r\n                                 \u89e6\u53d1supervisord\u53d1\u9001PROCESS_LOG_STDOUT\u7c7b\u578b\u7684event\r\n                                 \u9ed8\u8ba4\u4e3afalse\u3002\u3002\u3002\u975e\u5fc5\u987b\u8bbe\u7f6e\r\n;stderr_logfile=\/a\/path        ; \u8fd9\u4e2a\u4e1c\u897f\u662f\u8bbe\u7f6estderr\u5199\u7684\u65e5\u5fd7\u8def\u5f84\uff0c\u5f53redirect_stderr=true\u3002\u8fd9\u4e2a\u5c31\u4e0d\u7528\r\n                                 \u8bbe\u7f6e\u4e86\uff0c\u8bbe\u7f6e\u4e86\u4e5f\u662f\u767d\u642d\u3002\u56e0\u4e3a\u5b83\u4f1a\u88ab\u5199\u5165stdout_logfile\u7684\u540c\u4e00\u4e2a\u6587\u4ef6\u4e2d\r\n                                 \u9ed8\u8ba4\u4e3aAUTO\uff0c\u4e5f\u5c31\u662f\u968f\u4fbf\u627e\u4e2a\u5730\u5b58\uff0csupervisord\u91cd\u542f\u88ab\u6e05\u7a7a\u3002\u3002\u975e\u5fc5\u987b\u8bbe\u7f6e\r\n;stderr_logfile_maxbytes=1MB   ; \u8fd9\u4e2a\u51fa\u73b0\u597d\u51e0\u6b21\u4e86\uff0c\u5c31\u4e0d\u91cd\u590d\u4e86\r\n;stderr_logfile_backups=10     ; \u8fd9\u4e2a\u4e5f\u662f\r\n;stderr_capture_maxbytes=1MB   ; \u8fd9\u4e2a\u4e00\u6837\uff0c\u548cstdout_capture\u4e00\u6837\u3002 \u9ed8\u8ba4\u4e3a0\uff0c\u5173\u95ed\u72b6\u6001\r\n;stderr_events_enabled=false   ; \u8fd9\u4e2a\u4e5f\u662f\u4e00\u6837\uff0c\u9ed8\u8ba4\u4e3afalse\r\n;environment=A=\"1\",B=\"2\"       ; \u8fd9\u4e2a\u662f\u8be5\u5b50\u8fdb\u7a0b\u7684\u73af\u5883\u53d8\u91cf\uff0c\u548c\u522b\u7684\u5b50\u8fdb\u7a0b\u662f\u4e0d\u5171\u4eab\u7684\r\n;serverurl=AUTO                ;<\/pre>\n<p>\u6539\u6210\u81ea\u5df1\u5b9e\u9645\u7684\u914d\u7f6e\u6587\u4ef6\uff1a\u548c\u2460\u4e0a\u9762\u4e00\u6837\u3002<\/p>\n<p><strong><a href=\"http:\/\/supervisord.org\/running.html\" target=\"_blank\" rel=\"noopener noreferrer\">3\uff1a\u8fd0\u884c<\/a><\/strong><\/p>\n<p>1\uff09apt-get install \u5b89\u88c5\u7684supervisor\u76f4\u63a5\u53ef\u4ee5\u901a\u8fc7\u00a0<span class=\"s1\">\/etc\/init.d\/supervisor \u8fd0\u884c\uff1a<\/span><\/p>\n<div class=\"cnblogs_code\">\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">\/etc\/init.d\/supervisor start<\/pre>\n<\/div>\n<p>2\uff09\u901a\u8fc7easy_install \u5b89\u88c5\u7684supervisor\u8fd0\u884csupervisord \u8fd0\u884c\uff1a<\/p>\n<div class=\"cnblogs_code\">\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">supervisord<\/pre>\n<\/div>\n<p><strong>4\uff1aweb\u754c\u9762\u64cd\u4f5c<\/strong><\/p>\n<p>\u9700\u8981\u5728supervisor\u7684\u914d\u7f6e\u6587\u4ef6\u91cc\u6dfb\u52a0[inet_http_server]\u9009\u9879\u7ec4\uff1a\u4e4b\u540e\u53ef\u4ee5\u901a\u8fc7http:\/\/10.211.55.11:9001\u6765\u8bbf\u95ee\u63a7\u5236\u5b50\u7ebf\u7a0b\u7684\u7ba1\u7406\u3002<\/p>\n<div class=\"cnblogs_code\">\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">[inet_http_server]\r\nport=10.211.55.11:9001\r\nusername=user\r\npassword=123<\/pre>\n<\/div>\n<p>\u6548\u679c\uff1a<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/images2015.cnblogs.com\/blog\/163084\/201611\/163084-20161118021632920-889244058.png\" alt=\"\" width=\"691\" height=\"187\" \/><\/p>\n<p><strong><a href=\"http:\/\/supervisord.org\/running.html#running-supervisorctl\" target=\"_blank\" rel=\"noopener noreferrer\">5\uff1a\u5b50\u8fdb\u7a0b\u7ba1\u7406<\/a>(supervisorctl)<br \/>\n<\/strong><\/p>\n<p>1) \u67e5\u770b\u6240\u6709\u5b50\u8fdb\u7a0b\u7684\u72b6\u6001\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\"># supervisorctl status\r\nblog                             RUNNING    pid 2395, uptime 0:08:41\r\nzhoujy                           RUNNING    pid 2396, uptime 0:08:41<\/pre>\n<p>2\uff09\u5173\u95ed\u3001\u5f00\u542f\u6307\u5b9a\u7684\u5b50\u8fdb\u7a0b\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\"># supervisorctl stop zhoujy\r\nzhoujy: stopped\r\n\r\n# supervisorctl start zhoujy\r\nzhoujy: started<\/pre>\n<p>3\uff09\u5173\u95ed\u3001\u5f00\u542f\u6240\u6709\u7684\u5b50\u8fdb\u7a0b\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\"># supervisorctl stop all\r\nblog: stopped\r\nzhoujy: stopped\r\n# supervisorctl start all\r\nblog: started\r\nzhoujy: started<\/pre>\n<div class=\"cnblogs_code\">\n<pre><\/pre>\n<\/div>\n<p>4\uff09\uff1a\u5176\u4ed6\u53c2\u6570\uff1asupervisor\u5f00\u542f\u540e\u5b50\u8fdb\u7a0b\u81ea\u52a8\u5f00\u542f\uff08<strong>autostart=true<\/strong>\uff09\u548c\u5b50\u8fdb\u7a0b\u9000\u51fa\u540e\u81ea\u52a8\u542f\u52a8\uff08<strong>autorestart=ture<\/strong>\uff09<\/p>\n<p>\u66f4\u591a\u7684\u53c2\u6570\u53ef\u4ee5\u770b<a href=\"http:\/\/supervisord.org\/configuration.html\" target=\"_blank\" rel=\"noopener noreferrer\">\u5b98\u65b9\u6587\u6863<\/a>\u548c<a href=\"http:\/\/lixcto.blog.51cto.com\/4834175\/1539136\" target=\"_blank\" rel=\"noopener noreferrer\">supervisor(\u4e00)\u57fa\u7840\u7bc7<\/a>\u7684\u8bf4\u660e\u3002<\/p>\n<h2>\u603b\u7ed3\uff1a<\/h2>\n<p>\u6211\u4eec\u9700\u8981\u7684\u529f\u80fd\u5728\u4e0a\u9762\u4ecb\u7ecd\u7684supervisor\u7684\u57fa\u672c\u529f\u80fd\u4e2d\u5df2\u7ecf\u5b9e\u73b0\uff0csupervisor\u8fd8\u6709\u5176\u4ed6\u7684\u4e00\u4e9b\u529f\u80fd\uff1a\u5982\u8fdb\u7a0b\u7ec4\u3001web\u9875\u9762\u7ba1\u7406\u5b50\u8fdb\u7a0b\u3001\u76d1\u63a7\u5b50\u7ebf\u7a0b\u60c5\u51b5\u7b49\u7b49\uff0c\u66f4\u591a\u7684\u4fe1\u606f\u53ef\u4ee5\u53bb<a href=\"http:\/\/supervisord.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">\u5b98\u7f51<\/a>\u4e0a\u67e5\u770b\u3002<\/p>\n<h2>\u53c2\u8003\u6587\u6863\uff1a<\/h2>\n<p><a href=\"http:\/\/supervisord.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">Supervisor\u5b98\u65b9\u6587\u6863<\/a><\/p>\n<p><a href=\"http:\/\/lixcto.blog.51cto.com\/4834175\/1539136\" target=\"_blank\" rel=\"noopener noreferrer\">Supervisor(\u4e00)\u57fa\u7840\u7bc7<\/a><\/p>\n<p><a class=\"operlink\" title=\"supervisor(\u4e8c)event\" href=\"http:\/\/lixcto.blog.51cto.com\/4834175\/1540169\">Supervisor(\u4e8c)event<\/a><\/p>\n<p><a class=\"operlink\" title=\"supervisor(\u4e09)xml_rpc\" href=\"http:\/\/lixcto.blog.51cto.com\/4834175\/1540795\">Supervisor(\u4e09)xml_rpc<\/a><\/p>\n<\/div>\n<div class=\"clear\"><\/div>\n<div id=\"blog_post_info_block\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u80cc\u666f\uff1a \u9879\u76ee\u4e2d\u9047\u5230\u6709\u4e9b\u811a\u672c\u9700\u8981\u901a\u8fc7\u540e\u53f0\u8fdb<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"colormag_page_container_layout":"default_layout","colormag_page_sidebar_layout":"default_layout","footnotes":""},"categories":[],"tags":[117],"class_list":["post-2944","post","type-post","status-publish","format-standard","hentry","tag-01-linux"],"_links":{"self":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts\/2944","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/comments?post=2944"}],"version-history":[{"count":0,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts\/2944\/revisions"}],"wp:attachment":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/media?parent=2944"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/categories?post=2944"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/tags?post=2944"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}