Невозможно запустить celery через supervisord на aws eb при использовании условной проверки переменных env - PullRequest
0 голосов
/ 26 сентября 2019

Я проверяю переменную среды в моем файле ebextensions, чтобы условно создать сценарий supervisord для выполнения сельдерея в моей среде эластичных стеблей.

Он работает нормально без проверки if, но не выдает такую ​​ошибку процесса сif check

celeryd: ERROR (нет такого процесса) celeryd-index-application: ERROR (нет такого процесса) celeryd-send-comm: ERROR (нет такого процесса) celeryd-send-otp: ERROR (нет такогопроцесс) celeryd-приводит: ОШИБКА (без такого процесса) celeryd: ОШИБКА (без такого процесса) celeryd-index-application: ОШИБКА (без такого процесса) celeryd-send-comm: ОШИБКА (без такого процесса) celeryd-send-otp:ОШИБКА (нет такого процесса) celeryd-ведет: ОШИБКА (нет такого процесса)

files:
  "/opt/elasticbeanstalk/hooks/appdeploy/post/run_supervised_celeryd.sh":
    mode: "000755"
    owner: root
    group: root
    content: |
      #!/usr/bin/env bash

      # Get django environment variables
      celeryenv=`cat /opt/python/current/env | tr '\n' ',' | sed 's/export //g' | sed 's/%/%%/g' | sed 's/$PATH/%(ENV_PATH)s/g' | sed 's/$PYTHONPATH//g' | sed 's/$LD_LIBRARY_PATH//g'`
      runworker=`echo $celeryenv | sed 's/.*RUN_WORKER_JOB="//' | sed 's/",.*//'`
      if [ "$runworker" == "True" ]
        then
        celeryenv=${celeryenv%?}

        # Create celery configuration script
        celeryconf="[program:celeryd]
        ; Set full path to celery program if using virtualenv
        command=/opt/python/run/venv/bin/celery worker --app=pscore.celery --loglevel=INFO --concurrency=8 -Q publisher,celery

        directory=/opt/python/current/app/src
        user=wsgi
        numprocs=1
        stdout_logfile=/var/log/celery.log
        stderr_logfile=/var/log/celery.error.log
        autostart=true
        autorestart=true
        startsecs=10

        ; Need to wait for currently executing tasks to finish at shutdown.
        ; Increase this if you have very long running tasks.
        stopwaitsecs = 600

        ; When resorting to send SIGKILL to the program to terminate it
        ; send SIGKILL to its whole process group instead,
        ; taking care of its children as well.
        killasgroup=true

        ; if rabbitmq is supervised, set its priority higher
        ; so it starts first
        priority=998

        environment=$celeryenv

        [program:celeryd-index-application]
        ; Set full path to celery program if using virtualenv
        command=/opt/python/run/venv/bin/celery worker --app=pscore.celery --loglevel=INFO --concurrency=2 -Q index_applications

        directory=/opt/python/current/app/src
        user=wsgi
        numprocs=1
        stdout_logfile=/var/log/celery.log
        stderr_logfile=/var/log/celery.error.log
        autostart=true
        autorestart=true
        startsecs=10

        ; Need to wait for currently executing tasks to finish at shutdown.
        ; Increase this if you have very long running tasks.
        stopwaitsecs = 600

        ; When resorting to send SIGKILL to the program to terminate it
        ; send SIGKILL to its whole process group instead,
        ; taking care of its children as well.
        killasgroup=true

        ; if rabbitmq is supervised, set its priority higher
        ; so it starts first
        priority=998

        environment=$celeryenv

        [program:celeryd-send-comm]
        ; Set full path to celery program if using virtualenv
        command=/opt/python/run/venv/bin/celery worker --app=pscore.celery --loglevel=INFO --concurrency=2 -Q send_communication,send_communication_bulk

        directory=/opt/python/current/app/src
        user=wsgi
        numprocs=1
        stdout_logfile=/var/log/celery.log
        stderr_logfile=/var/log/celery.error.log
        autostart=true
        autorestart=true
        startsecs=10

        ; Need to wait for currently executing tasks to finish at shutdown.
        ; Increase this if you have very long running tasks.
        stopwaitsecs = 600

        ; When resorting to send SIGKILL to the program to terminate it
        ; send SIGKILL to its whole process group instead,
        ; taking care of its children as well.
        killasgroup=true

        ; if rabbitmq is supervised, set its priority higher
        ; so it starts first
        priority=998

        environment=$celeryenv

        [program:celeryd-send-otp]
        ; Set full path to celery program if using virtualenv
        command=/opt/python/run/venv/bin/celery worker --app=pscore.celery --loglevel=INFO --concurrency=2 -Q user_priority

        directory=/opt/python/current/app/src
        user=wsgi
        numprocs=1
        stdout_logfile=/var/log/celery.log
        stderr_logfile=/var/log/celery.error.log
        autostart=true
        autorestart=true
        startsecs=10

        ; Need to wait for currently executing tasks to finish at shutdown.
        ; Increase this if you have very long running tasks.
        stopwaitsecs = 600

        ; When resorting to send SIGKILL to the program to terminate it
        ; send SIGKILL to its whole process group instead,
        ; taking care of its children as well.
        killasgroup=true

        ; if rabbitmq is supervised, set its priority higher
        ; so it starts first
        priority=998

        environment=$celeryenv

        [program:celeryd-leads]
        ; Set full path to celery program if using virtualenv
        command=/opt/python/run/venv/bin/celery worker --app=pscore.celery --loglevel=INFO --concurrency=2 -Q process_leads_file

        directory=/opt/python/current/app/src
        user=wsgi
        numprocs=1
        stdout_logfile=/var/log/celery.leads.log
        stderr_logfile=/var/log/celery.leads.error.log
        autostart=true
        autorestart=true
        startsecs=10

        ; Need to wait for currently executing tasks to finish at shutdown.
        ; Increase this if you have very long running tasks.
        stopwaitsecs = 600

        ; When resorting to send SIGKILL to the program to terminate it
        ; send SIGKILL to its whole process group instead,
        ; taking care of its children as well.
        killasgroup=true

        ; if rabbitmq is supervised, set its priority higher
        ; so it starts first
        priority=998

        environment=$celeryenv"

        # Create the celery supervisord conf script
        echo "$celeryconf" | tee /opt/python/etc/celery.conf

        # Add configuration script to supervisord conf (if not there already)
        if ! grep -Fxq "[include]" /opt/python/etc/supervisord.conf
            then
            echo "[include]" | tee -a /opt/python/etc/supervisord.conf
            echo "files: channels.conf celery.conf" | tee -a /opt/python/etc/supervisord.conf
        elif ! grep -Fxq "files: channels.conf celery.conf" /opt/python/etc/supervisord.conf
            then
            sed -i -e "s/files\: .*/files: channels.conf celery.conf/g" /opt/python/etc/supervisord.conf
        fi

        # Reread the supervisord config
        /usr/local/bin/supervisorctl -c /opt/python/etc/supervisord.conf reread

        # Update supervisord in cache without restarting all services
        /usr/local/bin/supervisorctl -c /opt/python/etc/supervisord.conf update

        # Start/Restart celeryd through supervisord
        /usr/local/bin/supervisorctl -c /opt/python/etc/supervisord.conf restart celeryd celeryd-index-application celeryd-send-comm celeryd-send-otp celeryd-leads
      else
        echo 'RUN_WORKER_JOB is not set, skipping RUN_WORKER_JOB';
      fi

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...