求教 flask-nginx-uwsgi 中 processes 的开启 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
HelloViper
V2EX    Python

求教 flask-nginx-uwsgi 中 processes 的开启

  •  
  •   HelloViper 2021-01-25 16:43:15 +08:00 2014 次点击
    这是一个创建于 1790 天前的主题,其中的信息可能已经有所发展或是发生改变。

    uwsgi.ini 如下

    [uwsgi]

    #application's base folder

    base = /var/www/FlaskApp

    #python module to import

    app = FlaskApp

    module = %(app)

    #多线程

    processes = 3

    threads = 100

    #socket file's location

    socket = /var/www/FlaskApp/%n.sock

    enable-threads = true

    #permissions for the socket file

    chmod-socket = 666

    #the variable that holds a flask application inside the module imported at line #6

    callable = app

    #location of log files

    logto = /var/log/uwsgi/%n.log

    nginx.conf 如下:

    '''

    server { listen 80; server_name localhost; charset utf-8; client_max_body_size 75M; client_body_temp_path /tmp;

    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; } 

    }

    '''

    dockerfile 运行 ... CMD /etc/init.d/nginx start && uwsgi --ini /var/www/FlaskApp/app_uwsgi.ini

    docker-compose 后的日志:

    *** Starting uWSGI 2.0.19.1 (64bit) on [Fri Jan 22 18:34:18 2021] ***

    compiled with version: 7.5.0 on 27 November 2020 02:39:37

    os: Linux-4.15.0-54-generic #58-Ubuntu SMP Mon Jun 24 10:55:24 UTC 2019

    nodename: 17100a78a890

    machine: x86_64

    clock source: unix

    detected number of CPU cores: 1

    current working directory: /var/www/FlaskApp

    detected binary path: /usr/local/bin/uwsgi

    !!! no internal routing support, rebuild with pcre support !!!

    uWSGI running as root, you can use --uid/--gid/--chroot options

    *** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***

    *** WARNING: you are running uWSGI without its master process manager ***

    your memory page size is 4096 bytes

    detected max file descriptor number: 1048576

    lock engine: pthread robust mutexes

    thunder lock: disabled (you can enable it with --thunder-lock)

    uwsgi socket 0 bound to UNIX address /var/www/FlaskApp/app_uwsgi.sock fd 3 uWSGI running as root, you can use --uid/--gid/--chroot options

    *** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***

    Python version: 3.6.9 (default, Oct 8 2020, 12:12:24) [GCC 8.4.0]

    Python main interpreter initialized at 0x55ed96b56240

    uWSGI running as root, you can use --uid/--gid/--chroot options

    *** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***

    python threads support enabled

    your server socket listen backlog is limited to 100 connections

    your mercy for graceful operations on workers is 60 seconds

    mapped 72920 bytes (71 KB) for 1 cores

    *** Operational MODE: single process ***

    INFO:apscheduler.scheduler:Scheduler started

    WSGI app 0 (mountpoint='') ready in 10 seconds on interpreter 0x55ed96b56240 pid: 18 (default app)

    uWSGI running as root, you can use --uid/--gid/--chroot options

    *** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***

    *** uWSGI is running in multiple interpreter mode ***

    spawned uWSGI worker 1 (and the only) (pid: 18, cores: 1)

    求教大佬们为什么 uwsgi 只开了一个 worker /(ㄒoㄒ)/~~

    2 条回复    2021-01-26 15:40:37 +08:00
    neoblackcap
        1
    neoblackcap  
       2021-01-25 23:47:00 +08:00
    要不你试试多放几个核给你的容器试试?
    HelloViper
        2
    HelloViper  
    OP
       2021-01-26 15:40:37 +08:00
    @neoblackcap 本地的 Ubuntu 机器是 4 核的,docker-compose 依然是 spawned uWSGI worker 1 (and the only) (pid: 22, cores: 1)
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2387 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 25ms UTC 02:19 PVG 10:19 LAX 18:19 JFK 21:19
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86