{"id":317235,"date":"2021-02-04T11:13:40","date_gmt":"2021-02-04T03:13:40","guid":{"rendered":"http:\/\/4563.org\/?p=317235"},"modified":"2021-02-04T11:13:40","modified_gmt":"2021-02-04T03:13:40","slug":"%e6%b1%82%e6%95%99-flask-nginx-uwsgi-%e4%b8%ad-processes-%e7%9a%84%e5%bc%80%e5%90%af","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=317235","title":{"rendered":"\u6c42\u6559 flask-nginx-uwsgi \u4e2d processes \u7684\u5f00\u542f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u6c42\u6559 flask-nginx-uwsgi \u4e2d processes \u7684\u5f00\u542f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : HelloViper <\/span>  <span><i><\/i> 5<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>uwsgi.ini \u5982\u4e0b<\/p>\n<p>[uwsgi]<\/p>\n<p>#application&#8217;s base folder<\/p>\n<p>base = \/var\/www\/FlaskApp<\/p>\n<p>#python module to import<\/p>\n<p>app = FlaskApp<\/p>\n<p>module = %(app)<\/p>\n<p>#\u591a\u7ebf\u7a0b<\/p>\n<p>processes = 3<\/p>\n<p>threads = 100<\/p>\n<p>#socket file&#8217;s location<\/p>\n<p>socket = \/var\/www\/FlaskApp\/%n.sock<\/p>\n<p>enable-threads = true<\/p>\n<p>#permissions for the socket file<\/p>\n<p>chmod-socket = 666<\/p>\n<p>#the variable that holds a flask application inside the module imported at line #6<\/p>\n<p>callable = app<\/p>\n<p>#location of log files<\/p>\n<p>logto = \/var\/log\/uwsgi\/%n.log<\/p>\n<p>nginx.conf \u5982\u4e0b\uff1a<\/p>\n<p>&#8221;&#8217;<\/p>\n<p>server { listen 80; server_name localhost; charset utf-8; client_max_body_size 75M; client_body_temp_path \/tmp;<\/p>\n<pre><code>location \/static {     root \/var\/www\/FlaskApp\/FlaskApp; }  location \/ { try_files $uri @yourapplication; } location @yourapplication {     include uwsgi_params;   uwsgi_pass unix: \/var\/www\/FlaskApp\/uwsgi.sock; } <\/code><\/pre>\n<p>}<\/p>\n<p>&#8221;&#8217;<\/p>\n<p>dockerfile \u8fd0\u884c &#8230; CMD \/etc\/init.d\/nginx start &amp;&amp; uwsgi &#8211;ini \/var\/www\/FlaskApp\/app_uwsgi.ini<\/p>\n<p>docker-compose \u540e\u7684\u65e5\u5fd7\uff1a<\/p>\n<p>*** Starting uWSGI 2.0.19.1 (64bit) on [Fri Jan 22 18:34:18 2021] ***<\/p>\n<p>compiled with version: 7.5.0 on 27 November 2020 02:39:37<\/p>\n<p>os: Linux-4.15.0-54-generic #58-Ubuntu SMP Mon Jun 24 10:55:24 UTC 2019<\/p>\n<p>nodename: 17100a78a890<\/p>\n<p>machine: x86_64<\/p>\n<p>clock source: unix<\/p>\n<p>detected number of CPU cores: 1<\/p>\n<p>current working directory: \/var\/www\/FlaskApp<\/p>\n<p>detected binary path: \/usr\/local\/bin\/uwsgi<\/p>\n<p>!!! no internal routing support, rebuild with pcre support !!!<\/p>\n<p>uWSGI running as root, you can use &#8211;uid\/&#8211;gid\/&#8211;chroot options<\/p>\n<p>*** WARNING: you are running uWSGI as root !!! (use the &#8211;uid flag) ***<\/p>\n<p>*** WARNING: you are running uWSGI without its master process manager ***<\/p>\n<p>your memory page size is 4096 bytes<\/p>\n<p>detected max file descriptor number: 1048576<\/p>\n<p>lock engine: pthread robust mutexes<\/p>\n<p>thunder lock: disabled (you can enable it with &#8211;thunder-lock)<\/p>\n<p>uwsgi socket 0 bound to UNIX address \/var\/www\/FlaskApp\/app_uwsgi.sock fd 3 uWSGI running as root, you can use &#8211;uid\/&#8211;gid\/&#8211;chroot options<\/p>\n<p>*** WARNING: you are running uWSGI as root !!! (use the &#8211;uid flag) ***<\/p>\n<p>Python version: 3.6.9 (default, Oct 8 2020, 12:12:24) [GCC 8.4.0]<\/p>\n<p>Python main interpreter initialized at 0x55ed96b56240<\/p>\n<p>uWSGI running as root, you can use &#8211;uid\/&#8211;gid\/&#8211;chroot options<\/p>\n<p>*** WARNING: you are running uWSGI as root !!! (use the &#8211;uid flag) ***<\/p>\n<p>python threads support enabled<\/p>\n<p>your server socket listen backlog is limited to 100 connections<\/p>\n<p>your mercy for graceful operations on workers is 60 seconds<\/p>\n<p>mapped 72920 bytes (71 KB) for 1 cores<\/p>\n<p>*** Operational MODE: single process ***<\/p>\n<p>INFO:apscheduler.scheduler:Scheduler started<\/p>\n<p>WSGI app 0 (mountpoint=&#8221;) ready in 10 seconds on interpreter 0x55ed96b56240 pid: 18 (default app)<\/p>\n<p>uWSGI running as root, you can use &#8211;uid\/&#8211;gid\/&#8211;chroot options<\/p>\n<p>*** WARNING: you are running uWSGI as root !!! (use the &#8211;uid flag) ***<\/p>\n<p>*** uWSGI is running in multiple interpreter mode ***<\/p>\n<p>spawned uWSGI worker 1 (and the only) (pid: 18, cores: 1)<\/p>\n<p>\u6c42\u6559\u5927\u4f6c\u4eec\u4e3a\u4ec0\u4e48 uwsgi \u53ea\u5f00\u4e86\u4e00\u4e2a worker \/(\u3112o\u3112)\/~~<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>2<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5092900\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : neoblackcap <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8981\u4e0d\u4f60\u8bd5\u8bd5\u591a\u653e\u51e0\u4e2a\u6838\u7ed9\u4f60\u7684\u5bb9\u5668\u8bd5\u8bd5\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5092901\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : HelloViper <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @neoblackcap \u672c\u5730\u7684 Ubuntu \u673a\u5668\u662f 4 \u6838\u7684\uff0cdocker-compose \u4f9d\u7136\u662f spawned uWSGI worker 1 (and the only) (pid: 22, cores: 1)                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u6c42\u6559 flask-nginx-uw&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/317235"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=317235"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/317235\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=317235"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=317235"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=317235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}