Search code examples
celerytornadoflower

Celery Flower as Daemon


Im running celery with a redis backend. I want to run celery flower as a daemon on centos 6.2.

I understand flower is a Tornado application , so I should use a process to run a tornado application as a deamon.

Normally to start flower I use this command:

celery flower --broker=redis://localhost

I read at the below link that I need to create a python script as such: http://www.charleshooper.net/blog/python-starting-tornado-apps-at-boot-using-upstart/ (Startflower.py)

import tornado.ioloop
import tornado.web
import tornado.httpserver 

if __name__ == "__main__":
    http_server = tornado.httpserver.HTTPServer(application)
    http_server.listen(port)
    tornado.ioloop.IOLoop.instance().start()

However, I am unsure what to put in the 'application' variable. I tried 'celery flower --broker=redis://localhost' and 'celery flower" but neither worked

What do i need to do to get it working as a daemon??


Solution

  • You could keep it is as a command line program and run it under the supervisord daemon. This is a common solution in the python world (although supervisord works with any command, not just python), and I use it all the time.

    Supervisord makes the program think it is still running in a terminal. There are many examples how to use supervisord, but one that I use for a python proxy server can be found here, scroll down to "Installing the proxy server as a service".