{"id":3929,"date":"2018-05-19T21:06:54","date_gmt":"2018-05-19T13:06:54","guid":{"rendered":"https:\/\/ixyzero.com\/blog\/?p=3929"},"modified":"2018-05-19T21:06:54","modified_gmt":"2018-05-19T13:06:54","slug":"supervisor%e5%92%8cgunicorn%e9%97%ae%e9%a2%98%e8%ae%b0%e5%bd%95","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/3929.html","title":{"rendered":"supervisor\u548cgunicorn\u95ee\u9898\u8bb0\u5f55"},"content":{"rendered":"<p>=Start=<\/p>\n<h4 id=\"id-\u6a21\u677f-\u7f18\u7531\uff1a\">\u7f18\u7531\uff1a<\/h4>\n<p>\u57fa\u4e8eDjango\u5f00\u53d1\u7684Web\u5e94\u7528\u5728\u6027\u80fd\u4e0a\u4e00\u822c\u6bd4\u8f83\u5f31\uff0c\u5c24\u5176\u662f\u76f4\u63a5\u4ee5\u547d\u4ee4<code>python manage.py runserver<\/code>\u8fd9\u6837\u542f\u52a8\u7684\uff0c\u6240\u4ee5\u4e00\u822c\u5728\u7ebf\u4e0a\u90e8\u7f72\u7684\u65f6\u5019\uff0c\u4f1a\u5728\u524d\u9762\u52a0\u4e2aNginx\u505a\u8d1f\u8f7d\u5747\u8861\uff08\u5982\u679c\u53ef\u4ee5\u7684\u8bdd\u8fd8\u53ef\u4ee5\u7528\u7c7b\u4f3c\u4e8ekeepalived\u505a\u7aef\u53e3\/\u670d\u52a1\u5065\u5eb7\u68c0\u67e5\u3001\u6d41\u91cf\u5feb\u901f\u5207\u6362\u7b49\u9ad8\u7ea7\u529f\u80fd\uff09\uff0c\u540c\u65f6\u8fd8\u4f1a\u7528gunicorn\u8c03\u7528multiprocessing\u542f\u52a8\u591a\u4e2aPython\u8fdb\u7a0b\uff08\u5229\u7528socket\u6587\u4ef6\uff09\u76d1\u542c\u540c\u4e00\u7aef\u53e3\uff0c\u5e76\u4e14\u4e3a\u4e86\u9632\u6b62gunicorn\u8fdb\u7a0b\u5f02\u5e38\u6302\u6389\uff0c\u8fd8\u4f1a\u501f\u52a9supervisor\u8fd9\u4e2a\u5b88\u62a4\u8fdb\u7a0b\u8fdb\u884c\u76d1\u7ba1\u3002<\/p>\n<p>\u8fd9\u91cc\u8981\u4ecb\u7ecd\u7684\u5c31\u662f\u5728\u8fd9\u4e00\u8fc7\u7a0b\u4e2d\u78b0\u5230\u7684\u548csupervisor\u3001gunicorn\u76f8\u5173\u7684\u51e0\u4e2a\u95ee\u9898\uff0c\u65b9\u4fbf\u4ee5\u540e\u53c2\u8003\u3002<\/p>\n<h4 id=\"id-\u6a21\u677f-\u6b63\u6587\uff1a\">\u6b63\u6587\uff1a<\/h4>\n<h5 id=\"id-\u6a21\u677f-\u53c2\u8003\u89e3\u7b54\uff1a\">\u53c2\u8003\u89e3\u7b54\uff1a<\/h5>\n<h6>\u4e00\u4e9b\u524d\u7f6e\u6761\u4ef6\uff1a<\/h6>\n<ul>\n<li><strong>Python\u7248\u672c\uff08\u6e90\u7801\u5b89\u88c5\/yum\u5b89\u88c5\uff09<\/strong><\/li>\n<li><strong>Python\u6a21\u5757\uff08\u76f8\u5173\u6587\u4ef6\u62f7\u8d1d\/virtualenv\u91cd\u65b0\u5b89\u88c5\uff09<\/strong><\/li>\n<\/ul>\n<h6>supervisor\u7684\u5751\uff1a<\/h6>\n<ul>\n<li><span style=\"color: #ff0000;\"><strong>socket.error, [Errno 111] Connection refused<\/strong><\/span><\/li>\n<\/ul>\n<pre class=\"lang:default decode:true\"># \u5148\u542f\u52a8 supervisord\r\n$ supervisord -c supervisor.conf\r\n\r\n# \u518d\u7528 supervisorctl \u542f\u52a8\u7a0b\u5e8f\r\n# supervisord\u548csupervisorctl\u8981\u4f7f\u7528\u7684 supervisor.conf \u8981\u4e00\u81f4\uff0c\u5426\u5219\u4e5f\u4f1a\u51fa\u95ee\u9898\r\n$ supervisorctl -c supervisor.conf reload<\/pre>\n<h6>gunicorn\u7684\u5751\uff1a<\/h6>\n<ul>\n<li><strong>IOError(2, &#8216;No such file or directory&#8217;)<\/strong><\/li>\n<\/ul>\n<pre class=\"lang:default decode:true\">$ \/path\/to\/py27env\/bin\/gunicorn django_web.wsgi:application -c gunicorn.conf.py\r\nError: Error: '\/var\/logs\/django_web\/error.log' isn't writable [IOError(2, 'No such file or directory')]\r\n\r\n$ mkdir -p \/var\/logs\/django_web\/<\/pre>\n<ul>\n<li><span style=\"color: #ff0000;\"><strong>gunicorn.errors.HaltServer: &lt;HaltServer &#8216;Worker failed to boot.&#8217; 3&gt;<\/strong><\/span><\/li>\n<\/ul>\n<pre class=\"lang:default decode:true\">$ \/path\/to\/py27env\/bin\/gunicorn django_web.wsgi:application -c gunicorn.conf.py --log-level=debug\r\n\r\n$ \/path\/to\/py27env\/bin\/gunicorn django_web.wsgi:application -c gunicorn.conf.py --preload\r\n<\/pre>\n<p>&nbsp;<\/p>\n<h5 id=\"id-\u6a21\u677f-\u53c2\u8003\u94fe\u63a5\uff1a\">\u53c2\u8003\u94fe\u63a5\uff1a<\/h5>\n<ul>\n<li><a href=\"https:\/\/stackoverflow.com\/questions\/18859063\/supervisor-socket-error-issue\">https:\/\/stackoverflow.com\/questions\/18859063\/supervisor-socket-error-issue<\/a><\/li>\n<li><a href=\"http:\/\/pycode.cc\/supervisor-socket-error\/\">http:\/\/pycode.cc\/supervisor-socket-error\/<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/Supervisor\/supervisor\/issues\/121\">https:\/\/github.com\/Supervisor\/supervisor\/issues\/121<\/a><\/li>\n<li><a href=\"https:\/\/www.jianshu.com\/p\/687f0956081c\">https:\/\/www.jianshu.com\/p\/687f0956081c<\/a><\/li>\n<li><a href=\"https:\/\/www.gznotes.com\/supervisor-socket-error-errno-101\/\">https:\/\/www.gznotes.com\/supervisor-socket-error-errno-101\/<\/a><\/li>\n<li>=<\/li>\n<li><a href=\"https:\/\/stackoverflow.com\/questions\/24639907\/gunicorn-errors-haltserver-haltserver-worker-failed-to-boot-3\/30486771#30486771\">https:\/\/stackoverflow.com\/questions\/24639907\/gunicorn-errors-haltserver-haltserver-worker-failed-to-boot-3\/30486771#30486771<\/a><\/li>\n<\/ul>\n<p>=END=<\/p>\n","protected":false},"excerpt":{"rendered":"<p>=Start= \u7f18\u7531\uff1a \u57fa\u4e8eDjango\u5f00\u53d1\u7684Web\u5e94\u7528\u5728\u6027\u80fd\u4e0a\u4e00\u822c\u6bd4\u8f83\u5f31\uff0c\u5c24\u5176\u662f\u76f4\u63a5\u4ee5\u547d\u4ee4python ma [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,11,12],"tags":[1133,628],"class_list":["post-3929","post","type-post","status-publish","format-standard","hentry","category-knowledgebase-2","category-linux","category-tools","tag-gunicorn","tag-supervisor"],"views":9566,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/3929","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=3929"}],"version-history":[{"count":1,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/3929\/revisions"}],"predecessor-version":[{"id":3930,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/3929\/revisions\/3930"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=3929"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=3929"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=3929"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}