Is is possible to update a WSGI application without the need to reboot the server? I mean you can do that with WordPress. In WordPress you can install plugins, update them or even update the whole WordPress. How? Is it because it is written in PHP?
WordPress is not a WSGI application, but a PHP application. If you'd update PHP itself, you'd likely need to restart your web server as well.
The code for a WSGI application (like a Django application) is loaded into memory, together with an instance of Python itself. If you replace the application on disk, that instance in memory still needs to be replaced with the new application, by restarting it. Some servers allow doing that on the fly (like Apache with mod_wsgi
) but even in those situations it's generally recommended to restart the server.
However, if you run a WSGI application in a production environment, you would typically separate the web application server (like gunicorn or uWSGI) from the web server (like nginx or Apache). In that case, you only have to restart the application server running your application (and you could have separate application servers for separate applications), while the web server can remain live.
In a development environment, you'll typically use something like manage.py
with runserver
, which detects changes to the code and automatically performs the restart as needed. But of course that's entirely unsuitable for production use. However, if you need the fast reload as part of a develop & test cycle, that's the way to go. Deploying to production doesn't happen all that often and if you design your application well, users won't even notice the server has restarted in most cases.