参考了很多这个兄弟的? ? ?uwsgi + nginx 发布 - 逆欢 - 博客园??
FLASK项目中的uwsgi配置,配置的http方式
一.http 启动
[uwsgi]
http=0.0.0.0:5000
;socket = 81.71.70.7:5000
;virtualenv = /root/py38_env #支持http+socket两种方式,
chdir =/root/xxxxxxx/flask-celery
module = app
# 配置项目目录
wsgi-file=/root/xxxxx/xxxx/app.py
callable=app
processes = 4
threads = 4
buffer-size = 32768
# 开启master, 将会多开一个管理进程, 管理其他服务进程
master = true
# 退出的时候清空环境变量
vacuum = true
;py-autoreload=1
;daemonize =%(chdir)/uwsgi.log
;thunder-lock = true
#防止惊群
harakiri = 60
#超时时间(秒)
vacuum = true
;touch-logreopen = %(chdir)/logs/touchforlogrotate # 日志分割监听文件
验证下是否正常启动
uwsgi --ini uwsgi.ini
启动
[uWSGI] getting INI configuration from uwsgi.ini
*** Starting uWSGI 2.0.20 (64bit) on [Fri Mar 4 23:06:52 2022] ***
compiled with version: 4.8.5 20150623 (Red Hat 4.8.5-44) on 01 March 2022 01:05:51
os: Linux-3.10.0-1127.19.1.el7.x86_64 #1 SMP Tue Aug 25 17:23:54 UTC 2020
nodename: VM-1-34-centos
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 1
current working directory: /root/flask-celery-hjw/flask-celery
detected binary path: /root/py38_env/bin/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
chdir() to /root/flask-celery-hjw/flask-celery
your processes number limit is 15075
your memory page size is 4096 bytes
*** WARNING: you have enabled harakiri without post buffering. Slow upload could be rejected on post-unbuffered webservers ***
detected max file descriptor number: 100001
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uWSGI http bound on 0.0.0.0:5000 fd 4
uwsgi socket 0 bound to TCP address 127.0.0.1:43206 (port auto-assigned) 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.8.1 (default, Jul 29 2021, 02:34:47) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]
Python main interpreter initialized at 0xded360
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 1094880 bytes (1069 KB) for 16 cores
*** Operational MODE: preforking+threaded ***
定时任务1
定时任务2
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0xded360 pid: 23094 (default app)
mountpoint already configured. skip.
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 master process (pid: 23094)
spawned uWSGI worker 1 (pid: 23098, cores: 4)
spawned uWSGI worker 2 (pid: 23099, cores: 4)
spawned uWSGI worker 3 (pid: 23101, cores: 4)
spawned uWSGI worker 4 (pid: 23102, cores: 4)
spawned uWSGI http 1 (pid: 23103)
关闭??
杀死uwsgi
kill -9 继承的pid
nginx的相关配置
进入 vi /etc/nginx/nginx.conf文件? ?
查看是否有文件
vi /etc/nginx/uwsgi_params.default
修改文件名
vi /etc/nginx/uwsgi_params.default /etc/nginx/uwsgi_params
拷贝文件
cp /etc/nginx/uwsgi_params.default /etc/nginx/uwsgi_params
进入 vi /etc/nginx/nginx.conf 写入
http {
server {
listen 80 ;
access_log /usr/local/nginx/logs/access.log ;
error_log /usr/local/nginx/logs/error.log ;
# server {
location / {
include uwsgi_params ;
# include /usr/local/nginx/conf/uwsgi_params ;
proxy_pass http://81.71.70.7:5000 ;
# uwsgi_pass 81.71.70.7:5000 ;
}
}
}
80端口的监听?
访问日志和错误日志在access.log 和error.log中? ?
就可以正常访问了? ,直接输入地址?
|