Search code examples
unixsshceleryflower

Can I configure Celery Flower to run after I close my Unix shell?


I have inherited a corporate server & application that consists of several python scripts, html files, and Unix services from an IT employee that recently left my company. He left absolutely no documentation, so I'm struggling to support this application for my work group--I am not an IT professional (though I can read/write python, html, and a few other languages). I'm extremely unfamiliar with servers in general and Unix specifically.

From what I can tell from digging around, our application uses the following:

  • nginx
  • circus / gunicorn
  • rabbitmq-server
  • celery
  • celery flower

I've finally got most of these services running, but I'm struggling with Celery Flower. I've been able to launch Flower from my PuTTY SSH connection with the command:

/miniconda3/envs/python2/bin/flower start

but it appears to stop whenever I disconnect (server:5555 no longer shows the monitor web page). Is it possible to configure it to run in the background so I don't have to keep my SSH connection open 24/7? I saw in the Flower documentation that there is a persistence mode, but I'm not sure what does.

Thanks for any suggestions!


Solution

  • Tom, I assume you are using a Linux platform. If this is the case I suggest you use screen (or even tmux) to run Flower. It will keep the application running in the background as well as offer the additional benefit of allowing you to connect back to the process if you need to inspect output, stop the process, etc.

    To start the application use screen -S Flower -d -m /miniconda3/envs/python2/bin/flower start.

    To see if the process is still running use screen -ls which will list the processes out like;

    There is a screen on:
        17256.Flower    (02/09/16 08:01:16) (Detached)
    1 Socket in /var/run/screen/S-hooligan.
    

    To connect back to it, use screen -r Flower.

    If you have connected back to the screen then disconnect with ^a ^d, assuming the escape character has not been changed from the default. To see a full list of key bindings look the the man page, it's pretty straight forward.

    You might also consider adding this command to the system crontab with a @REBOOT directive so that it starts when the system boots.