本文介绍了Flask + mod_wsgi自动重新加载源代码更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道如何让一个使用 mod_wsgi , WSGIScriptReloading 更改 .wsgi 配置文件,而不是代码。



我的工作流程是上传我的代码更改那么只需

$ $ p $ $ $ c $ $ $ MyWebApp.wsgi
$ / code>

导致上次修改的文件时间戳发生变化, mod_wsgi 重新加载代码。



您可以通过将本地计算机上的 .wsgi 文件保存并重新上传,或者通过SSH进行远程 p>

对于语法错误,您可以做的不多,代码可以运行,也可以不运行,但是一个修正加上 touch 会再次运行。



有一个问题需要注意,如果你通过FTP工作:make确定你上传的是感动 .wsgi 文件 last ,否则它会尝试从错误的代码开始。


Does anyone know how to make a mod_wsgi automatically reload a Flask app when any of the modules changes? I've tried WSGIScriptReloading On, but no luck. The official documentation is kind of a bear ... I guess I'll give it a stab if no one knows. Thanks in advance!

Also, if it could not permanently crash on syntax errors (like the the Flask reloader), that'd be awesome.

解决方案

With mod_wsgi, WSGIScriptReloading looks for changes to the .wsgi config file, rather than the code.

My workflow is to upload my code changes then just

$ touch MyWebApp.wsgi

which causes the last modified file timestamp to change and mod_wsgi to reload the code.

You can do this 'remotely' by saving the .wsgi file on your local machine and then uploading it again, or I just do it via SSH.

Not a lot you can do about syntax errors, the code is either running or it isn't, but a fix plus a touch will get it running again.

One gotcha to look out for if you're working via FTP: make sure you upload the 'touched' .wsgi file last otherwise it'll try and start with the wrong code.

这篇关于Flask + mod_wsgi自动重新加载源代码更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 23:32