Django代码更改时是否需要重新启动uWSGI? [英] Does uWSGI need to be restarted when Django code changes?
问题描述
我正在使用在nginx和uWSGI下运行的Django Web应用程序.当我部署新的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-reload uWSGI参数可能会有所帮助.
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屋!