Created
January 3, 2014 01:30
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if I'm using a docker python container, what would I put in place of the virtual env paths?