{"id":2464,"date":"2013-01-28T10:22:25","date_gmt":"2013-01-28T02:22:25","guid":{"rendered":"https:\/\/kyle.ai\/blog\/?p=2464"},"modified":"2013-01-28T10:22:25","modified_gmt":"2013-01-28T02:22:25","slug":"%e7%94%a8supervisor%e7%ae%a1%e7%90%86%e8%bf%9b%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/kyle.ai\/blog\/2464.html","title":{"rendered":"\u7528Supervisor\u7ba1\u7406\u8fdb\u7a0b"},"content":{"rendered":"<p><span style=\"font-size: small;\">supervisor\u5730\u5740\uff1ahttp:\/\/supervisord.org\uff0c\u5b98\u65b9\u6807\u8bed\u5c31\u662f\uff1a\u4e00\u4e2a\u8fdb\u7a0b\u7ba1\u7406\u5de5\u5177\u3002<\/span><\/p>\n<p><span style=\"font-size: small;\">\u5b89\u88c5\uff1a<\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo apt-get install supervisor # pip\/easy_install\r\n<\/pre>\n<p><span style=\"font-size: small;\">\u5b89\u88c5\u597d\u4ee5\u540e\uff0c\u6709\u4e24\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\u548c\u4e00\u4e2a\u914d\u7f6e\u6587\u4ef6\uff08\u5e73\u53f0\u5dee\u5f02\uff0c\u53ef\u80fd\u8def\u5f84\u4e0d\u4e00\u81f4\uff09\uff1a<\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\/usr\/bin\/supervisord             --  supervisor\u670d\u52a1\u5b88\u62a4\u8fdb\u7a0b\r\n\/usr\/bin\/supervisorctl           --  supervisor\u670d\u52a1\u63a7\u5236\u7a0b\u5e8f\uff0c\u6bd4\u5982\uff1astatus\/start\/stop\/restart xx \u7b49\r\n\/etc\/supervisor\/supervisord.conf --  \u914d\u7f6e\u6587\u4ef6\uff0c\u5b9a\u4e49\u670d\u52a1\u540d\u79f0\u4ee5\u53ca\u63a5\u53e3\u7b49\u7b49\r\n<\/pre>\n<p><span style=\"font-size: small;\">Supervisor \u6709\u4e24\u4e2a\u53ef\u6267\u884c\u7a0b\u5e8f \u2013 supervisord \u548c supervisorctl:<\/span><\/p>\n<p><span style=\"font-size: small;\">supervisord \u662f\u540e\u53f0\u7ba1\u7406\u670d\u52a1\u5668, \u7528\u6765\u4f9d\u636e\u914d\u7f6e\u6587\u4ef6\u7684\u7b56\u7565\u7ba1\u7406\u540e\u53f0\u5b88\u62a4\u8fdb\u7a0b, \u5b83\u4f1a\u968f\u7cfb\u7edf\u81ea\u52a8\u542f\u52a8<\/span><br \/>\n<span style=\"font-size: small;\"> supervisorctl \u7528\u4e8e\u7ba1\u7406\u5458\u5411\u540e\u53f0\u7ba1\u7406\u7a0b\u5e8f\u53d1\u9001 \u542f\u52a8\/\u91cd\u542f\/\u505c\u6b62 \u7b49\u6307\u4ee4;<\/span><br \/>\n<span style=\"font-size: small;\"> \u5b83\u4eec\u4e4b\u95f4\u7684\u5173\u7cfb\u5c31\u76f8\u5f53\u4e8e Apache \u7684 httpd \u548c apachectl.<\/span><\/p>\n<p><span style=\"font-size: small;\">supervisord\uff0c\u521d\u59cb\u542f\u52a8Supervisord\uff0c\u542f\u52a8\u3001\u7ba1\u7406\u914d\u7f6e\u4e2d\u8bbe\u7f6e\u7684\u8fdb\u7a0b\u3002<\/span><br \/>\n<span style=\"font-size: small;\"> supervisorctl stop programxxx\uff0c\u505c\u6b62\u67d0\u4e00\u4e2a\u8fdb\u7a0b(programxxx)\uff0cprogramxxx\u4e3a[program:chatdemon]\u91cc\u914d\u7f6e\u7684\u503c\uff0c\u8fd9\u4e2a\u793a\u4f8b\u5c31\u662fchatdemon\u3002<\/span><br \/>\n<span style=\"font-size: small;\"> supervisorctl start programxxx\uff0c\u542f\u52a8\u67d0\u4e2a\u8fdb\u7a0b<\/span><br \/>\n<span style=\"font-size: small;\"> supervisorctl restart programxxx\uff0c\u91cd\u542f\u67d0\u4e2a\u8fdb\u7a0b<\/span><br \/>\n<span style=\"font-size: small;\"> supervisorctl stop all\uff0c\u505c\u6b62\u5168\u90e8\u8fdb\u7a0b\uff0c\u6ce8\uff1astart\u3001restart\u3001stop\u90fd\u4e0d\u4f1a\u8f7d\u5165\u6700\u65b0\u7684\u914d\u7f6e\u6587\u4ef6\u3002<\/span><br \/>\n<span style=\"font-size: small;\"> supervisorctl reload\uff0c\u8f7d\u5165\u6700\u65b0\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u5e76\u6309\u65b0\u7684\u914d\u7f6e\u542f\u52a8\u3001\u7ba1\u7406\u6240\u6709\u8fdb\u7a0b\u3002<\/span><\/p>\n<p><span style=\"font-size: small;\">\u914d\u7f6e\u6587\u4ef6\uff1a<\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&#x5B;inet_http_server]\r\n; Web\u7ba1\u7406\u754c\u9762\u8bbe\u5b9a\r\nport=9001\r\nusername = admin\r\npassword = yourpassword\r\n\r\n; \u7ba1\u7406\u7684\u5355\u4e2a\u8fdb\u7a0b\u7684\u914d\u7f6e\uff0c\u53ef\u4ee5\u6dfb\u52a0\u591a\u4e2aprogram\r\n; \u6587\u6863 http:\/\/supervisord.org\/configuration.html#program-x-section-settings\r\n&#x5B;program:py-chess]\r\n; command \u5b57\u6bb5\u8bbe\u7f6e\u7684\u662f\u540e\u53f0\u5b88\u62a4\u5e94\u7528\u7684\u542f\u52a8\u547d\u4ee4,\r\n; \u6ce8\u610f: \u8be5\u547d\u4ee4\u5fc5\u987b\u662f\u5728\u524d\u53f0\u6267\u884c\u7684, \u5373\u4f1a\u72ec\u5360\u63a7\u5236\u53f0, \u5426\u5219\u4f1a\u5bfc\u81f4 supervisor \u65e0\u6cd5\u83b7\u5f97\u6807\u51c6\u8f93\u51fa, \u5e76\u5931\u53bb\u8fdb\u7a0b\u7684\u63a7\u5236\u6743.\r\ncommand=python \/var\/www\/py-chess\/app.py\r\nautostart = true\r\nstartsecs = 5\r\nuser = root\r\nredirect_stderr = true\r\nstdout_logfile = \/var\/log\/supervisord\/py-chess.log\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>supervisor\u5730\u5740\uff1ahttp:\/\/supervisord.org\uff0c\u5b98\u65b9\u6807\u8bed\u5c31\u662f\uff1a\u4e00\u4e2a\u8fdb\u7a0b\u7ba1\u7406\u5de5\u5177\u3002 \u5b89\u88c5 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-2464","post","type-post","status-publish","format-standard","hentry","category-skill"],"_links":{"self":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/2464","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/comments?post=2464"}],"version-history":[{"count":1,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/2464\/revisions"}],"predecessor-version":[{"id":2465,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/2464\/revisions\/2465"}],"wp:attachment":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/media?parent=2464"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/categories?post=2464"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/tags?post=2464"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}