Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 芹菜守护程序脚本与init脚本不在后台运行_Python_Django_Daemon_Django Celery - Fatal编程技术网

Python 芹菜守护程序脚本与init脚本不在后台运行

Python 芹菜守护程序脚本与init脚本不在后台运行,python,django,daemon,django-celery,Python,Django,Daemon,Django Celery,芹菜医生说 但是,在生产环境中,您可能希望在后台将worker作为守护进程运行。 我制作了init.d脚本,如下所示 #!/bin/sh # # chkconfig: 345 99 15 # description: celery init.d # Where to chdir at start. CELERYD_CHDIR="/home/username/django/django_myapp" # How to call "manage.py celeryd_multi" CELERYD

芹菜医生说

但是,在生产环境中,您可能希望在后台将worker作为守护进程运行。

我制作了init.d脚本,如下所示

#!/bin/sh
#
# chkconfig: 345 99 15
# description: celery init.d 
# Where to chdir at start.
CELERYD_CHDIR="/home/username/django/django_myapp"

# How to call "manage.py celeryd_multi"
CELERYD="/opt/python27/bin/python manage.py celeryd "

#CELERYD_MULTI="$CELERYD_CHDIR/manage.py celeryd_multi"

# Extra arguments to celeryd
CELERYD_OPTS="--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="-B -l info"

    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
当我执行
/etc/init.d/celeryd start

现在它运行良好,但再次出现在前景中,而不是背景中


是这样还是我做错了

我在芹菜和初始化脚本方面也遇到了类似的问题,最终还是和主管一起去了。头疼的事要少得多。我不确定,但celeryd可能足够聪明,可以决定是否有终端可用,如果没有,就转到后台。你试过完全重新启动吗?但我不能在终端打开的情况下启动和停止吗?我必须启动和停止很多次。我还试过打开新的终端,试过
stop
,它说celeryd没有运行,但它在另一个终端上运行。为什么