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 · 1522 次点击
    这是一个创建于 1396 天前的主题,其中的信息可能已经有所发展或是发生改变。

    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   ·   实用小工具   ·   5358 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 07:49 · PVG 15:49 · LAX 23:49 · JFK 02:49
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.