{"id":5407,"date":"2016-10-06T02:06:12","date_gmt":"2016-10-05T18:06:12","guid":{"rendered":"https:\/\/sdeno.com\/?p=5407"},"modified":"2016-10-06T02:06:12","modified_gmt":"2016-10-05T18:06:12","slug":"ubuntu%e5%90%8e%e5%8f%b0%e8%bf%9b%e7%a8%8b%e7%ae%a1%e7%90%86%e5%88%a9%e5%99%a8%ef%bc%9asupervisor","status":"publish","type":"post","link":"https:\/\/sdeno.com\/?p=5407","title":{"rendered":"ubuntu\u540e\u53f0\u8fdb\u7a0b\u7ba1\u7406\u5229\u5668\uff1asupervisor"},"content":{"rendered":"<p><strong>\u5b89\u88c5supervisor<\/strong><\/p>\n<pre>sudo apt-get install supervisor<\/pre>\n<p>\u7136\u540e\uff0c\u7ed9\u6211\u4eec\u81ea\u5df1\u5f00\u53d1\u7684\u5e94\u7528\u7a0b\u5e8f\u7f16\u5199\u4e00\u4e2a\u914d\u7f6e\u6587\u4ef6\uff0c\u8ba9supervisor\u6765\u7ba1\u7406\u5b83\u3002\u6bcf\u4e2a\u8fdb\u7a0b\u7684\u914d\u7f6e\u6587\u4ef6\u90fd\u53ef\u4ee5\u5355\u72ec\u5206\u62c6\uff0c\u653e\u5728\/etc\/supervisor\/conf.d\/\u76ee\u5f55\u4e0b\uff0c\u4ee5.conf\u4f5c\u4e3a\u6269\u5c55\u540d\uff0c\u4f8b\u5982\uff0capp.conf\u5b9a\u4e49\u4e86\u4e00\u4e2agunicorn\u7684\u8fdb\u7a0b\uff1a<\/p>\n<pre>[program:app]\r\ncommand=\/usr\/bin\/gunicorn -w 1 wsgiapp:application\r\ndirectory=\/srv\/www\r\nuser=www-data<\/pre>\n<p>\u5176\u4e2d\uff0c\u8fdb\u7a0bapp\u5b9a\u4e49\u5728[program:app]\u4e2d\uff0ccommand\u662f\u547d\u4ee4\uff0cdirectory\u662f\u8fdb\u7a0b\u7684\u5f53\u524d\u76ee\u5f55\uff0cuser\u662f\u8fdb\u7a0b\u8fd0\u884c\u7684\u7528\u6237\u8eab\u4efd\u3002<\/p>\n<p>\u91cd\u542fsupervisor\uff0c\u8ba9\u914d\u7f6e\u6587\u4ef6\u751f\u6548\uff0c\u7136\u540e\u8fd0\u884c\u547d\u4ee4supervisorctl\u542f\u52a8\u8fdb\u7a0b\uff1a<\/p>\n<pre># supervisorctl start app<\/pre>\n<p>\u505c\u6b62\u8fdb\u7a0b\uff1a<\/p>\n<pre># supervisorctl stop app<\/pre>\n<p style=\"color: #666666;\">\u5982\u679c\u8981\u5728\u547d\u4ee4\u884c\u4e2d\u4f7f\u7528\u53d8\u91cf\uff0c\u5c31\u9700\u8981\u81ea\u5df1\u5148\u7f16\u5199\u4e00\u4e2ashell\u811a\u672c\uff1a<\/p>\n<pre style=\"color: #444444;\"><code class=\"ruby\"><span class=\"comment\" style=\"font-style: italic; color: #999988;\">#!\/bin\/sh<\/span>\r\n\/usr\/bin\/gunicorn -w `grep -c ^processor \/proc\/cpuinfo` <span class=\"symbol\" style=\"color: #990073;\">wsgiapp:<\/span>application\r\n<\/code><\/pre>\n<p style=\"color: #666666;\">\u7136\u540e\uff0c\u52a0\u4e0ax\u6743\u9650\uff0c\u518d\u628acommand\u6307\u5411\u8be5shell\u811a\u672c\u5373\u53ef\u3002<\/p>\n<p style=\"color: #666666;\">supervisor\u8fd8\u6709\u8bb8\u591a\u9009\u9879\uff0c\u9ed8\u8ba4\u7684autorestart\u4e3aunexpected\uff08\u5f02\u5e38\u9000\u51fa\uff09\uff0c\u5177\u4f53\u8bf7\u53c2\u8003<a style=\"color: #0593d3;\" href=\"http:\/\/supervisord.org\/\" target=\"_blank\">supervisor\u6587\u6863<\/a>\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b89\u88c5supervisor sudo apt-get install supervisor \u7136\u540e\uff0c\u7ed9\u6211\u4eec\u81ea\u5df1\u5f00\u53d1 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[39],"tags":[],"class_list":["post-5407","post","type-post","status-publish","format-standard","hentry","category-ubuntu"],"_links":{"self":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/5407","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5407"}],"version-history":[{"count":0,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/5407\/revisions"}],"wp:attachment":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5407"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5407"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5407"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}