Forums

What is the preferred way to update existing apps without taking down the site?

I have apps live and want to update them from my local development environment without them being temporarily unavailable. What are my options? [paid plan]

If you have a staging site on PythonAnywhere, you can use that to test your new code in the environment it's going to run in. Then, once you're sure it's going to work, you can move the code to your live site and reload the web app to get the new code. The web server will finish the requests it's working on and then start up with the new code. If your web app doesn't take too long to start up, then your users will probably not even notice (we do the equivalent of this for emergency live fixes to the PythonAnywhere code and nobody ever notices)

Of course, this only applies to code changes. If you have database migrations that are not backwards compatible, you'll have to take the site down to apply them. That'a a much harder problem and the solution will depend heavily on your code and your coding practices.

Is there a way to do this through a CLI tool automatically?

Sure. Just touch your wsgi file and that will reload the web app.

Just for clarity -- the WSGI file Glenn is talking about is the one in /var/www/, called something like www_yourdomain_com_wsgu.py. Not any WSGI file that your web framework happens to have put into your source code (Django, for example, creates one for itself), which will probably be ignored on PythonAnywhere.