部署工具
uwsgi+django+nginx+supervisor
Uwsgi
参考链接
大江狗的blog
实例
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
| [uwsgi]
chdir=/home/wind_speed/speed
module=speed.wsgi
home=/home/speed/speed_venv
master=true
processes=1
socket=:4002
chmod-socket=664 chown-socket=www-data
stats=%(chdir)/uwsgi/uwsgi.status
pidfile=%(chdir)/uwsgi/uwsgi.pid
static-map = /static=%(chdir)/static
vacuum=true
|
Nginx
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| server{ listen 4011; server_name 120.78.194.246; client_max_body_size 75M;
location /static { alias /home/wind_speed/speed/static; }
location / { uwsgi_pass 127.0.0.1:4002; include /etc/nginx/uwsgi_params; } }
|
alias解释 散尽浮华的blog
server_name解释csnd
## Nginx 根目录重定向 1 2 3
| if ($request_uri ~* "^/$") { rewrite / https://www.reach-power.tech permanent; }
|
# Supervisor ## 参考链接 简书M_GBO
实例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| [program:wind_speed]
command=/home/wind_speed/speed/uwsgi --ini uwsgi.ini
directory=/home/wind_speed/speed
user=root
autostart=true
autorestart=true startsecs=1
stderr_logfile=/var/log/supervisor/wind_speed/error.log stdout_logfile=/var/log/supervisor/wind_speed/speed.log
|
常用命令
参考链接
supervisor用法-亚楠老猎人
实例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| # nginx 重启 service nginx restart service nginx reload
# uwsgi启动 uwsgi --ini uwsgi.ini # uwsgi重启 uwsgi --reload uwsgi.pid # uwsgi关闭 uwsgi --stop uwsgi.pid
# 关闭所有任务 supervisorctl shutdown # 启动某个进程 supervisorctl start programxxx # 重启某个进程 supervisorctl restart programxxx # 停止全部进程 注:start、restart、stop都不会载入最新的配置文件 supervisorctl stop all # 载入最新的配置文件,停止原有进程并按新的配置启动、管理所有进程。 supervisorctl reload # 根据最新的配置文件,启动新配置或有改动的进程,配置没有改动的进程不会受影响而重启。 supervisorctl update
|