uwsgi 热部署 热启动 热更新

uwsgi选项大全:https://uwsgi-docs-zh.readthedocs.io/zh_CN/latest/Options.html

uwsgi官方热部署建议:https://uwsgi-docs-zh.readthedocs.io/zh_CN/latest/articles/TheArtOfGracefulReloading.html

我这里介绍一下使用

touch-reload https://uwsgi-docs-zh.readthedocs.io/zh_CN/latest/articles/TheArtOfGracefulReloading.html#sighup

选项提供的热部署方法。还有两个相似选项:

touch-workers-reloadhttps://uwsgi-docs-zh.readthedocs.io/zh_CN/latest/articles/TheArtOfGracefulReloading.html#lazy-appsworker

touch-chain-reloadhttps://uwsgi-docs-zh.readthedocs.io/zh_CN/latest/articles/TheArtOfGracefulReloading.html#lazy-apps

uwsgi的选项使用方法有两种:

1,在启动uwsgi的命令中加入选项,但选项前必须带--(两横)

2,在配置文件中拿一行出来填入一个选项,不带--

通常启动uwsgi的命令中要指定配置文件,比如:

$ /home/me/py/venvs/web1/bin/uwsgi /home/me/py/www/web1/uwsgi.ini
#第一个是虚拟环境中的uwsgi程序,第二个是配置文件

所以怎么加选项就看你自己了。

选项有两种,一种必须带参数,一种不带参数。

方法1中,带参数直接在选项后隔个空格加入参数,不带的就不用加,如:

$ /home/me/py/venvs/web1/bin/uwsgi /home/me/py/www/web1/uwsgi.ini --touch-chain-reload <文件路径> --lazy-apps
#两个选项,touch-chain-reload和lazy-apps

方法2中,带参数的就用个等号加参数,不带的就用等号加个true,如:

[uwsgi]
touch-chain-reload = <文件路径>
lazy-apps = true
(...其他配置)

lazy-apps选项请参考(https://uwsgi-docs-zh.readthedocs.io/zh_CN/latest/articles/TheArtOfGracefulReloading.html#preforking-vs-lazy-apps-vs-lazy

但我发现这三种touch选项只能对单个文件生效,而不能指定文件夹,目前就只能多指定几个关键文件了。

如果使用supervisor管理,需要在配置更改后restart项目。

原文地址:https://www.cnblogs.com/oler/p/13510535.html