af83

Daemonizing a tornado app

Tornado logo

This post is more a note for myself than anything else, but I wrote it here as it can also be useful for you. It explains how to daemonize a tornado application in three easy steps:

  1. Install python-daemon

  2. Add this import line at the beginning of  my-app.py:

import daemon
  1. Add these 3 lines in the main() function, just before the tornado.ioloop.IOLoop.instance().start():
log = open('tornado.' + str(port) + '.log', 'a+')
ctx = daemon.DaemonContext(stdout=log, stderr=log,  working_directory='.')
ctx.open()

That's all folks.

blog comments powered by Disqus