重启uwsgi

        每次我在客户端把代码push到服务器后,都要去服务器重启uwsgi,相当麻烦。想写个脚本来监控git的更新。查看了git手册后,发现它有好几个hooks,这些hooks分别会监控不同的git命令。hooks钩子如下:

applypatch-msg.sample  
commit-msg.sample  
post-receive  
post-update.sample  
pre-applypatch.sample  
pre-commit.sample  
prepare-commit-msg.sample  
pre-rebase.sample  
update.sample

这些都是shell脚本,去掉后面的sample后就能运行相应git命令脚本了。每个钩子的作用详见:http://gitbook.liuhui998.com/5_8.html

当用户在本地仓库执行'git-push'命令时,服务器上运端仓库就会对应执行'git-receive-pack'命令,而'git-receive-pack'命令会调用 pre-receive 钩子。在开始更新远程仓库上的ref之前,这个钩子被调用。钩子的执行结果(exit status)决定此次更新能否成功。

在post-receive加如下语句:

kill -HUP `cat /dev/shm/webapp.pid`

如果有 /etc/init.d/uwsgi, 就用 /etc/init.d/uwsgi restart,没有的话kill -HUP好了。

在webapp的uwsgi_webapp.xml配置里添加

<pidfile>/dev/shm/webapp.pid</pidfile>

如果是ini后缀的配置文件:

pidfile=/dev/shm/webapp.pid

如果要uwsgi随着服务器的启动而启动,怎么配置呢?

修改/etc/rc.local文件:

/usr/local/bin/uwsgi -x /web/www/webapp/uwsgi_webapp.xml -d /var/log/uwsgi/uwsgi.log

最好使用uwsgi的完整路径

python,go,redis,mongodb,.net,C#,F#,服务器架构
原文地址:https://www.cnblogs.com/descusr/p/3070556.html