最后,我将我的开发环境从runserver迁移到gunicorn/nginx。
将runserver的自动重新加载功能复制到gunicorn会很方便,这样当源发生变化时,服务器就会自动重启。否则,我必须使用kill -HUP
手动重新启动服务器。
有什么方法可以避免手动重启吗?
发布于 2014-07-23 00:40:01
虽然这是一个老问题,但您需要知道,从19.0版开始,gunicorn
就有了--reload
选项。所以现在不需要第三方工具了。
发布于 2013-06-13 12:30:54
一种选择是通过将--max-requests 1
添加到启动选项,使用--max-requests将每个衍生的进程限制为只服务一个请求。每个新产生的进程都应该看到代码更改,并且在开发环境中,每个请求的额外启动时间应该可以忽略不计。
发布于 2013-10-22 03:24:55
Bryan Helmig想出了这个,我将其修改为使用run_gunicorn
而不是直接启动gunicorn
,这样就可以将这3个命令剪切并粘贴到您的django项目根文件夹中的shell中(并激活您的virtualenv ):
pip install watchdog -U
watchmedo shell-command --patterns="*.py;*.html;*.css;*.js" --recursive --command='echo "${watch_src_path}" && kill -HUP `cat gunicorn.pid`' . &
python manage.py run_gunicorn 127.0.0.1:80 --pid=gunicorn.pid
https://stackoverflow.com/questions/12773763
复制相似问题