Skip to content

Instantly share code, notes, and snippets.

@rodrigogadea
Created January 3, 2014 01:30
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rodrigogadea/8230898 to your computer and use it in GitHub Desktop.
Save rodrigogadea/8230898 to your computer and use it in GitHub Desktop.
Quick and Dirty bash script to daemonize Flower - i.e. /etc/init.d/flower
#!/bin/bash
NAME=flower
DESC="flower daemon"
# Name of the projects settings module.
export DJANGO_SETTINGS_MODULE="yourproject.settings"
# Path to virtualenv
ENV_PYTHON="/home/youruser/.virtualenvs/yourvirtualenv/bin/python"
# Where the Django project is.
FLOWER_CHDIR="/path/to/your/project"
# How to call "manage.py celery flower" (args...)
FLOWERCTL="$FLOWER_CHDIR/manage.py celery flower --url_prefix=flower"
DAEMON=$FLOWERCTL
set -e
case "$1" in
start)
echo -n "Starting $DESC: "
# Activate the virtual environment
. /home/youruser/.virtualenvs/webcassette/bin/activate
. /home/youruser/.virtualenvs/webcassette/bin/postactivate
start-stop-daemon --start --pidfile /var/run/$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/run/$NAME.pid
rm -f /var/run/$NAME.pid
echo "$NAME."
;;
esac
exit 0
@ajwillo
Copy link

ajwillo commented Sep 25, 2017

if I'm using a docker python container, what would I put in place of the virtual env paths?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment