-
-
Save appunni-m/2ec6fc22e872c880b78c71fd37dd927e 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 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" | |
USER=USER | |
VIRTUALENV=VIRTUALENV | |
PROJECT=PROJECT | |
# Name of the projects settings module. | |
export DJANGO_SETTINGS_MODULE="$PROJECT.settings" | |
# Path to virtualenv | |
ENV_PYTHON="/home/$USER/.virtualenvs/$VIRTUALENV/bin/python" | |
# Where the Django project is. | |
FLOWER_CHDIR="/home/$USER/$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/$USER/.virtualenvs/$VIRTUALENV/bin/activate | |
. /home/$USER/.virtualenvs/$VIRTUALENV/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