调优UWSGI,后台启动,热更改PY,杜绝502

时间:2023-03-09 02:41:40
调优UWSGI,后台启动,热更改PY,杜绝502

调优UWSGI,后台启动,热更改PY,杜绝502

记得加启动参数: --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 &

记得先

  1. yum -y install inotify-tools