Is There A Way To Deploy New Code With Tornado/python Without Restarting The Server?
Solution 1:
It appears the best method is to use Nginx with multiple Tornado instances as I alluded to in my original question and as Cole mentions. Nginx can reload its configuration file on the fly . So the process looks like this:
- Update Python/Tornado web application code
- Start a new instance of the application on a different port
- Update the configuration file of Nginx to point to the new instance (testing the syntax of the configuration file first)
- Reload the Nginx configuration file with a
kill -HUP
command - Stop the old instance of Python/Tornado web server
A couple useful resources on Nginx regarding hot-swapping the configuration file:
https://calomel.org/nginx.html (in "Explaining the directives in nginx.conf" section) http://wiki.nginx.org/CommandLine (in "Loading a New Configuration Using Signals" section)
Solution 2:
Use HAProxy or Nginx and proxy to multiple Tornado processes, which you can then restart one by one. The Tornado docs cover Nginx, but it doesn't support websockets, so if you're using them you'll need HAProxy.
Solution 3:
You could use a debug=True switch with the tornado web instance.
T_APP = tornado.web.Application(<URL_MAP>, debug=True)
This reflects the handler changes as and when they happen.
Solution 4:
Is this what you are searching for?
A module to automatically restart the server when a module is modified. http://www.tornadoweb.org/en/branch2.4/autoreload.html
Solution 5:
If you just want to deploy new code with tornado/python during development without restarting the server, you can use the realtimefunc
decorator in this GitHub repository.
Post a Comment for "Is There A Way To Deploy New Code With Tornado/python Without Restarting The Server?"