记得加启动参数: --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 0 fi if [ $1 = start ] then psid=`ps aux | grep "uwsgi" | grep -v "grep" | wc -l` if [ $psid -gt 4 ] then echo "uwsgi is running!" exit 0 else uwsgi /xxx/www/uwsgi.ini --daemonize /var/log/uwsgi.log --post-buffering 32768 --buffer-size 32768 echo "Start uwsgi service [OK]" fi elif [ $1 = stop ];then killall -9 uwsgi echo "Stop uwsgi service [OK]" elif [ $1 = restart ];then killall -9 uwsgi uwsgi --ini /xxx/www/uwsgi.ini --daemonize /var/log/uwsgi.log --post-buffering 32768 --buffer-size 32768 --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