django代码更改时需要重启uWSGI吗? [英] Does uWSGI need to be restarted when Django code changes?
问题描述
我正在开发一个在 nginx 和 uWSGI 下运行的 Django 网络应用程序.当我部署新的 Django 代码(例如,settings.py)时,是否需要重新启动 uWSGI?如果是,为什么?
I'm working on a Django webapp that's running under nginx and uWSGI. When I deploy new Django code (e.g., settings.py), do I need to restart uWSGI? If so, why?
背景:我有一个场景,我更新了 settings.py 和其他一些代码并部署了它.直到我重新启动 uWSGI,我才看到 webapp 行为的变化.
Background: I had a scenario where I updated settings.py and some other code and deployed it. I did not see the changes in the webapp behavior until I restarted uWSGI.
推荐答案
是的,需要重启uWSGI进程.
Yes, you need to restart the uWSGI process.
Python 将编译后的代码保存在内存中,因此在进程重新启动之前不会被重新读取.django 开发服务器 (manage.py runserver
) 主动监视文件的更改,但默认情况下其他服务器不会发生这种情况.如果你想在 uWSGI 中启用自动重新加载,touch-reload 和 py-auto-reloaduWSGI 参数可能会有所帮助.
Python keeps the compiled code in memory so it won't get re-read until the process restarts. The django development server (manage.py runserver
) actively monitors files for changes, but that won't happen by default with other servers. If you want to enable automatic reloading in uWSGI, the touch-reload and py-auto-reload uWSGI arguments might help.
这篇关于django代码更改时需要重启uWSGI吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!