Flower: How to start flower as daemon?

Created on 10 Jul 2017  路  3Comments  路  Source: mher/flower

I'm trying to start flower as daemon but couldn't find any material online. Im using RHEL 7.3.

Most helpful comment

I use the following script to daemonize Flower.
Just place it in /etc/init.d/

#!/bin/bash

NAME=flower
DESC="flower daemon"

# Name of the projects settings module.
export DJANGO_SETTINGS_MODULE="yourproject.settings"

# Path to virtualenv
ENV_PYTHON="/usr/bin/python3"

# Where the Django project is.
FLOWER_CHDIR=" "

# How to call "manage.py celery flower" (args...)
FLOWERCTL="/usr/local/bin/flower -A tasks --port=5555"
DAEMON=$FLOWERCTL

set -e

case "$1" in
  start)
        echo -n "Starting $DESC: "

        start-stop-daemon --start --pidfile /var/tmp/$NAME.pid \
            --chdir $FLOWER_CHDIR --chuid celery \
            --user celery --group celery --background \
            --make-pidfile \
            --exec "$ENV_PYTHON" -- $FLOWERCTL
        echo "$NAME."
        ;;

  stop)
        echo -n "Stopping $DESC: "
        start-stop-daemon --stop --quiet --oknodo \
            --pidfile /var/tmp/$NAME.pid
        rm -f /var/tmp/$NAME.pid
        echo "$NAME."
        ;;
esac

exit 0

All 3 comments

Have you tried supervisor ? I use it for both Celery and Flower, and it works like a charm.

can you give me an example how that I can implement?

I use the following script to daemonize Flower.
Just place it in /etc/init.d/

#!/bin/bash

NAME=flower
DESC="flower daemon"

# Name of the projects settings module.
export DJANGO_SETTINGS_MODULE="yourproject.settings"

# Path to virtualenv
ENV_PYTHON="/usr/bin/python3"

# Where the Django project is.
FLOWER_CHDIR=" "

# How to call "manage.py celery flower" (args...)
FLOWERCTL="/usr/local/bin/flower -A tasks --port=5555"
DAEMON=$FLOWERCTL

set -e

case "$1" in
  start)
        echo -n "Starting $DESC: "

        start-stop-daemon --start --pidfile /var/tmp/$NAME.pid \
            --chdir $FLOWER_CHDIR --chuid celery \
            --user celery --group celery --background \
            --make-pidfile \
            --exec "$ENV_PYTHON" -- $FLOWERCTL
        echo "$NAME."
        ;;

  stop)
        echo -n "Stopping $DESC: "
        start-stop-daemon --stop --quiet --oknodo \
            --pidfile /var/tmp/$NAME.pid
        rm -f /var/tmp/$NAME.pid
        echo "$NAME."
        ;;
esac

exit 0
Was this page helpful?
0 / 5 - 0 ratings