开发者

init.d celery script for CentOS?

I'm writing a Django app that uses celery. So far 开发者_如何转开发I've been running on Ubuntu, but I'm trying to deploy to CentOS.

Celery comes with a nice init.d script for Debian-based distributions, but it doesn't work on RedHat-based distributions like CentOS because it uses start-stop-daemon. Does anybody have an equivalent one for RedHat that uses the same variable conventions so I can reuse my /etc/default/celeryd file?


Is better solved here:

Celery CentOS init script

You should be good using that one


Since I didn't get an answer, I tried to roll my own:

#!/bin/sh
#
# chkconfig: 345 99 15
# description: celery init.d script

# Defines the following variables
# CELERYD_CHDIR
# DJANGO_SETTINGS_MODULE
# CELERYD
# CELERYD_USER
# CELERYD_GROUP
# CELERYD_LOG_FILE

CELERYD_PIDFILE=/var/run/celery.pid

if test -f /etc/default/celeryd; then
    . /etc/default/celeryd
fi


# Source function library.
. /etc/init.d/functions

# Celery options
CELERYD_OPTS="$CELERYD_OPTS -f $CELERYD_LOG_FILE -l $CELERYD_LOG_LEVEL"

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜