Celeryd 启动脚本

2011-09-29
  • 分享一个 celeryd 的****启动脚本

    #!/bin/bash

    chkconfig: 345 99 15

    description: celery init.d

    Where to chdir at start.

    CELERYD_CHDIR="/path/to/djproject/"

    How to call "manage.py celeryd_multi"

    CELERYD="/usr/bin/python manage.py celeryd " #CELERYD_MULTI="$CELERYD_CHDIR/manage.py celeryd_multi"

    Extra arguments to celeryd

    CELERYD_OPTS="--beat --time-limit 300 --concurrency=8"

    Name of the celery config module.

    CELERY_CONFIG_MODULE="celeryconfig"

    %n will be replaced with the nodename.

    CELERYD_LOG_FILE="/var/log/celery/%n.log" CELERYD_PID_FILE="/var/run/celery/%n.pid"

    Workers should run as an unprivileged user.

    CELERYD_USER="root" CELERYD_GROUP="celery"

    Name of the projects settings module.

    export DJANGO_SETTINGS_MODULE="settings" CELERYD_PIDFILE=/var/run/celery.pid # Source function library. . /etc/init.d/functions # Celery options CELERYD_OPTS="-l INFO -B -f /var/log/celery/celery.log --pidfile=${CELERYD_PIDFILE}" if [ -n "$2" ]; then CELERYD_OPTS="$CELERYD_OPTS $2" fi start () { cd $CELERYD_CHDIR daemon --user $CELERYD_USER --pidfile $CELERYD_PIDFILE $CELERYD $CELERYD_OPTS & } stop () { if [[ -s $CELERYD_PIDFILE ]] ; then echo "Stopping Celery" killproc -p $CELERYD_PIDFILE python echo "done!" rm -f $CELERYD_PIDFILE else echo "Celery not running." fi } check_status() { status -p $CELERYD_PIDFILE python } case "$1" in start) start ;; stop) stop ;; restart) stop start ;; status) check_status ;; *) echo "Usage: $0 {start|stop|restart|status}" exit 1 ;; esac