Skip to content Skip to sidebar Skip to footer

Is There A Way To Deploy New Code With Tornado/python Without Restarting The Server?

I've recently started to experiment with Python and Tornado web server/framework for web development. Previously, I have used PHP with my own framework on a LAMP stack. With PHP,

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:

  1. Update Python/Tornado web application code
  2. Start a new instance of the application on a different port
  3. Update the configuration file of Nginx to point to the new instance (testing the syntax of the configuration file first)
  4. Reload the Nginx configuration file with a kill -HUP command
  5. 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?"