![调优UWSGI,后台启动,热更改PY,杜绝502 调优UWSGI,后台启动,热更改PY,杜绝502](https://image.shishitao.com:8440/aHR0cHM6Ly9ia3FzaW1nLmlrYWZhbi5jb20vdXBsb2FkL2NoYXRncHQtcy5wbmc%2FIQ%3D%3D.png?!?w=700&webp=1)
记得加启动参数: --daemonize /var/log/uwsgi.log --post-buffering 32768 --buffer-size 32768
reload.set
#!/bin/bash if [ ! -n "$1" ] then echo "Usages: sh uwsgiserver.sh [start|stop|restart]" exit fi = start ] then psid=`ps aux | grep "uwsgi" | grep -v "grep" | wc -l` ] then echo "uwsgi is running!" exit else uwsgi /xxx/www/uwsgi.ini --daemonize /var/log/uwsgi.log --post-buffering --buffer-size echo "Start uwsgi service [OK]" fi = stop ];then uwsgi echo "Stop uwsgi service [OK]" = restart ];then uwsgi uwsgi --ini /xxx/www/uwsgi.ini --daemonize /var/log/uwsgi.log --post-buffering --buffer-size --touch-reload "/xxx/www/reload.set" echo "Restart uwsgi service [OK]" else echo "Usages: sh uwsgiserver.sh [start|stop|restart]" fi
autoreload.sh
#!/bin/sh objectdir="/xxx/www/" # 启动inotify监视项目目录, 参数"--exclude" 为忽略的文件或目录正则 /usr/local/bin/inotifywait -mrq --exclude "(static|logs|shell|\.swap|\.pyc|\.swx|\.py\~)" --timefmt '%d/%m/%y %H:%M' --format '%T %w%f' --event modify,delete,move,create,attrib ${objectdir} | while read files do /bin/touch /xxx/www/reload.set continue done &
记得先
- yum -y install inotify-tools