我遇到了这个问题的变化 - 正如Pokomy先生所链接的文章中所建议的,用HUP
信号杀死gunicorn主进程似乎有诀窍。
如果您使用python watchdog
模块,可以轻松设置文件自动重装;设置其实是不言自明的,所以这里从我的发展supervisord.conf文件的一个片段:实际上不是在conf文件换行符之前
[program:ost2]
autostart=true
command=/usr/local/share/python/gunicorn --debug\
-c /Users/fish/Dropbox/ost2/ost2/utils/gunicorn/ost2-debug.py wsgi_debug
directory=/Users/fish/Dropbox/ost2/ost2
priority=500
; (etc)
[program:ost2-reloader]
autostart=true
autorestart=false
directory=/tmp
command=/usr/local/share/python/watchmedo shell-command\
--patterns="*.py;*.txt;*.html;*.css;*.less;*.js;*.coffee"\
-R --command='kill -HUP $(cat /usr/local/gunicorn/gunicorn.pid)'\
/Users/fish/Dropbox/ost2/ost2/
priority=996
; (etc)
(注:我把斜线是样本中 - 我插入这些换行符的易读性;我不确定这是否工作IRL)
第一个程序是gunicorn进程,我在开发过程中运行一个单线程以使用Werkzeug调试器。第二部分是有趣的一点:该命令说,“如果文件的后缀与该列表中的一个匹配,则在该目录树中的文件发生更改时,终止由gunicorn PID文件指定的进程”。
对于包括我在内的许多人来说,它就像一种魅力。如果你不知道,watchdog
是非常有用的,值得一看,在它自己的权利。
这很棒,如果您使用主管来管理gunicorn,您可以将您的cat命令替换为:supervisorctl status gunicorn_task_name | sed -e's /.* pid \([0-9] \ {1,5 \} \)。*/\ 1/g' – 2013-04-12 21:43:32