0%

部署django + uwsgi

django + uwsgi 配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# uwsig使用配置文件启动
[uwsgi]
# 项目目录
chdir = /home/www/report/
# 指定项目的application
module = report.wsgi:application
# 指定sock的文件路径
socket = /home/www/report/conf/uwsgi.sock
# 进程个数
workers = 5
pidfile = /home/www/report/conf/uwsgi.pid
# 指定IP端口
http = 0.0.0.0:8888
# 指定静态文件
static-map = /static=/home/www/report/static
# 启动uwsgi的用户名和用户组
uid = root
gid = root
# 启用主进程
master = true
# 自动移除unix Socket和pid文件当服务停止的时候
vacuum = true
# 序列化接受的内容,如果可能的话
thunder-lock = true
# 启用线程
enable-threads = true
# 设置自中断时间
harakiri = 30
# 设置缓冲
post-buffering = 4096
# 设置日志目录
# daemonize = /home/www/report/conf/uwsgi.log
home = /root/.local/share/virtualenvs/report-kHgYRlIp

flask + uwsgi 配置

1
2
3
4
5
6
7
8
9
10
[uwsgi]
http = 0.0.0.0:8888
pythonpath = /home/ubuntu/www/index
wsgi-file = /home/ubuntu/www/index/app.py
callable = app
processes = 1
threads = 10
demonize = /home/ubuntu/www/index/log/serve.log
home = /home/ubuntu/.local/share/virtualenvs/index-1SLxCpRK

uwsgi 启动

1
2
3
4
5
6
# 启动(可以加-d守护进程启动)
uwsgi --ini xxx.ini
## 重启
uwsgi --reload xxx.pid
#### 停止:
uwsgi --stop xxx.pid