【问题标题】:init.d celery script for CentOS?CentOS 的 init.d 芹菜脚本?
【发布时间】:2011-04-28 17:27:33
【问题描述】:

我正在编写一个使用 celery 的 Django 应用程序。到目前为止,我一直在 Ubuntu 上运行,但我正在尝试部署到 CentOS。

Celery 为基于 Debian 的发行版提供了一个不错的 init.d 脚本,但它不适用于 CentOS 等基于 RedHat 的发行版,因为它使用 start-stop-daemon。有没有人有一个等效的 RedHat 使用相同的变量约定,所以我可以重用我的 /etc/default/celeryd 文件?

【问题讨论】:

    标签: centos celery


    【解决方案1】:

    最好在这里解决:

    Celery CentOS init script

    你应该很好用那个

    【讨论】:

    【解决方案2】:

    由于我没有得到答案,我试着自己动手:

    #!/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
    

    【讨论】:

    • 嗨洛林,我和你处于同一阶段。我查看了基本文档,但无法让它在 CentOS 上运行,这对你有用吗?
    • ApPel:我已经有一段时间没有看到这个了。我认为这几乎可行。我遇到的问题是,如果我执行“ssh node service celeryd restart”之类的操作,它将重新启动服务器,但我没有得到提示。这意味着它不能用像织物这样的东西正确地自动化。
    猜你喜欢
    • 2011-07-01
    • 2012-01-08
    • 2015-01-02
    • 2014-04-13
    • 2013-05-09
    • 1970-01-01
    • 2013-09-29
    • 2011-04-05
    • 1970-01-01
    相关资源
    最近更新 更多