Flask + mod_wsgi automatic reload on source code change

前端 未结 6 821
旧时难觅i
旧时难觅i 2021-01-04 08:10

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 n

6条回答
  •  花落未央
    2021-01-04 08:56

    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.

提交回复
热议问题