2

Just started learning python flask framework, after going through few tutorials i found that for every change which me make in (init.py) file or any of the python file we need to restart the server for the change to be commited. Well i dont get it for instance if a user going through one of the page on server(single server) with payment page(not necessarily a payment gateway), what happens if the server needs to be restarted for any change committed in the back end,Is there any way to handle this, Sorry if my questions seems inappropriate i am just a newbie.

Bhanu Teja
  • 341
  • 5
  • 10
  • 1
    When you deploy your code to production environment, there is predefined release process in which your new code is deployed. Once the deployment is successfull, you restart the apache. You won't be making changes in your production code. For local testing, you do not need apache. Just run the development wsgi server of Flask/Django and your changes will be reflected without restarting the server – Moinuddin Quadri Dec 16 '16 at 17:25
  • thank you @MoinuddinQuadri actually the tutorials which i went through were being implemented directly on the production server rather than first testing in the local then deploying on the production server,so thats what i was confused a bit. Yeah now i got clarified thank you ! – Bhanu Teja Dec 16 '16 at 17:33
  • You should not have to restart Apache. It's just a reverse proxy to your Flask server application. The only thing that has to deal with changed code is that web app server. There seem to be various ways to restart that one on code change, even automatically, for instance see http://stackoverflow.com/questions/16344756/auto-reloading-python-flask-app-upon-code-changes – Irmen de Jong Dec 16 '16 at 19:18

1 Answers1

3

For details on how code reloading is handled under Apache/mod_wsgi read:

If you are using daemon mode (which you should be using anyway) you do not need to restart the whole Apache web server, you can just touch the WSGI script file.

You can also add in a code change monitor that detects changes and restarts processes automatically, but if you are doing development and are targeting Apache/mod_wsgi for production, you are better off using mod_wsgi-express for development.

The mod_wsgi-express package allows you easily to start up Apache/mod_wsgi on a non privileged port from the command line without you needing to do any Apache configuration yourself. One of the options it then provides is --reload-on-changes so that it will automatically reload code for you as you make changes.

For details on mod_wsgi-express see the PyPi documentation at:

Graham Dumpleton
  • 57,726
  • 6
  • 119
  • 134