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

2021-01-25 16:43:15 +08:00
 HelloViper

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ㄒ)/~~

1357 次点击
所在节点    Python
2 条回复
neoblackcap
2021-01-25 23:47:00 +08:00
要不你试试多放几个核给你的容器试试?
HelloViper
2021-01-26 15:40:37 +08:00
@neoblackcap 本地的 Ubuntu 机器是 4 核的,docker-compose 依然是 spawned uWSGI worker 1 (and the only) (pid: 22, cores: 1)

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/748213

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX