0

나는 탄력적 인 beanstalk 환경에 Django Channels을 추가하고 있지만, 실행 중 문제가 발생하여 supervisord을 구성 중입니다.AWS 환경에서 supervisord 실행하기

container_commands: 
    01_copy_supervisord_conf: 
    command: "cp .ebextensions/supervisord/supervisord.conf /opt/python/etc/supervisord.conf" 
    02_reload_supervisord: 
    command: "supervisorctl -c /opt/python/etc/supervisord.conf reload" 

탄성 콩나무의 CLI를 통해 다음과 같은 오류 메시지와 함께 2 명령에이 오류 것은 :

Command failed on instance. Return code: 1 Output: error: <class 
    'FileNotFoundError'>, [Errno 2] No such file or directory: 
    file: /opt/python/run/venv/local/lib/python3.4/site- 
    packages/supervisor/xmlrpc.py line: 562. 
    container_command 02_reload_supervisord in 
    .ebextensions/channels.config failed. 

내 생각은 supervisor을 것 특히, /.ebextensions에이 코드와 파일 channels.config이 올바르게 설치되지 않았지만 명령 1이 오류없이 파일을 복사하기 때문에 supervisor이 실제로 설치되었다고 생각되며 이로 인해 컨테이너 명령에 문제가 있습니다. AWS 환경에서 supervisor을 구현 한 사람이 어디서 잘못 볼 수 있습니까? 여기

그것이 어쩌면

여기
packages: 
    yum: 
    python27-setuptools: [] 
container_commands: 
    01-supervise: 
    command: ".ebextensions/supervise.sh" 

도움을 줄 수 않았다 방법

답변

1

당신은 파이썬 버전과 정확한 설치 경로에주의해야한다는 supervise.sh

#!/bin/bash 
if [ "${SUPERVISE}" == "enable" ]; then 

export HOME="/root" 
export PATH="/sbin:/bin:/usr/sbin:/usr/bin:/opt/aws/bin" 

easy_install supervisor 

cat <<'EOB' > /etc/init.d/supervisord 

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

    # Source system settings 
    if [ -f /etc/sysconfig/supervisord ]; then 
     . /etc/sysconfig/supervisord 
    fi 

    # Path to the supervisorctl script, server binary, 
    # and short-form for messages. 
    supervisorctl=${SUPERVISORCTL-/usr/bin/supervisorctl} 
    supervisord=${SUPERVISORD-/usr/bin/supervisord} 
    prog=supervisord 
    pidfile=${PIDFILE-/var/run/supervisord.pid} 
    lockfile=${LOCKFILE-/var/lock/subsys/supervisord} 
    STOP_TIMEOUT=${STOP_TIMEOUT-60} 
    OPTIONS="${OPTIONS--c /etc/supervisord.conf}" 
    RETVAL=0 

    start() { 
     echo -n $"Starting $prog: " 
     daemon --pidfile=${pidfile} $supervisord $OPTIONS 
     RETVAL=$? 
     echo 
     if [ $RETVAL -eq 0 ]; then 
      touch ${lockfile} 
      $supervisorctl $OPTIONS status 
     fi 
     return $RETVAL 
    } 

    stop() { 
     echo -n $"Stopping $prog: " 
     killproc -p ${pidfile} -d ${STOP_TIMEOUT} $supervisord 
     RETVAL=$? 
     echo 
     [ $RETVAL -eq 0 ] && rm -rf ${lockfile} ${pidfile} 
    } 

    reload() { 
     echo -n $"Reloading $prog: " 
     LSB=1 killproc -p $pidfile $supervisord -HUP 
     RETVAL=$? 
     echo 
     if [ $RETVAL -eq 7 ]; then 
      failure $"$prog reload" 
     else 
      $supervisorctl $OPTIONS status 
     fi 
    } 

    restart() { 
     stop 
     start 
    } 

    case "$1" in 
     start) 
      start 
      ;; 
     stop) 
      stop 
      ;; 
     status) 
      status -p ${pidfile} $supervisord 
      RETVAL=$? 
      [ $RETVAL -eq 0 ] && $supervisorctl $OPTIONS status 
      ;; 
     restart) 
      restart 
      ;; 
     condrestart|try-restart) 
      if status -p ${pidfile} $supervisord >&/dev/null; then 
       stop 
       start 
      fi 
      ;; 
     force-reload|reload) 
      reload 
      ;; 
     *) 
      echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|reload}" 
      RETVAL=2 
    esac 

    exit $RETVAL 
    EOB 

     chmod +x /etc/init.d/supervisord 

     cat <<'EOB' > /etc/sysconfig/supervisord 
    # Configuration file for the supervisord service 
    # 
    # Author: Jason Koppe <[email protected]> 
    #    orginal work 
    #   Erwan Queffelec <[email protected]> 
    #    adjusted to new LSB-compliant init script 

    # make sure elasticbeanstalk PARAMS are being passed through to supervisord 
    . /opt/elasticbeanstalk/support/envvars 

    # WARNING: change these wisely! for instance, adding -d, --nodaemon 
    # here will lead to a very undesirable (blocking) behavior 
    #OPTIONS="-c /etc/supervisord.conf" 
    PIDFILE=/var/run/supervisord/supervisord.pid 
    #LOCKFILE=/var/lock/subsys/supervisord.pid 

    # Path to the supervisord binary 
    SUPERVISORD=/usr/local/bin/supervisord 

    # Path to the supervisorctl binary 
    SUPERVISORCTL=/usr/local/bin/supervisorctl 

    # How long should we wait before forcefully killing the supervisord process ? 
    #STOP_TIMEOUT=60 

    # Remove this if you manage number of open files in some other fashion 
    #ulimit -n 96000 
    EOB 

     mkdir -p /var/run/supervisord/ 
     chown webapp: /var/run/supervisord/ 

     cat <<'EOB' > /etc/supervisord.conf 
    [unix_http_server] 
    file=/tmp/supervisor.sock 
    chmod=0777 

    [supervisord] 
    logfile=/var/app/support/logs/supervisord.log 
    logfile_maxbytes=0 
    logfile_backups=0 
    loglevel=warn 
    pidfile=/var/run/supervisord/supervisord.pid 
    nodaemon=false 
    nocleanup=true 
    user=webapp 

    [rpcinterface:supervisor] 
    supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface 

    [supervisorctl] 
    serverurl=unix:///tmp/supervisor.sock 

    [program:process-ipn-api-gpsfsoft] 
    command = -- command that u want to run --- 
    directory = /var/app/current/ 
    user = webapp 
    autorestart = true 
    startsecs = 0 
    numprocs = 10 
    process_name = -- process name that u want --- 

    EOB 

     # this is now a little tricky, not officially documented, so might break but it is the cleanest solution 
     # first before the "flip" is done (e.g. switch between ondeck vs current) lets stop supervisord 
     echo -e '#!/usr/bin/env bash\nservice supervisord stop' > /opt/elasticbeanstalk/hooks/appdeploy/enact/00_stop_supervisord.sh 
     chmod +x /opt/elasticbeanstalk/hooks/appdeploy/enact/00_stop_supervisord.sh 
     # then right after the webserver is reloaded, we can start supervisord again 
     echo -e '#!/usr/bin/env bash\nservice supervisord start' > /opt/elasticbeanstalk/hooks/appdeploy/enact/99_z_start_supervisord.sh 
     chmod +x /opt/elasticbeanstalk/hooks/appdeploy/enact/99_z_start_supervisord.sh 
    fi 

입니다 추신 :이 실행을 얻으려면 Elasticbeanstalk 환경 값에서 SUPERVISE를 Enable로 정의하십시오.

+0

이것은 도움이되지만 컨테이너 명령을 통해 스크립트를 호출 할 때 권한 오류가 발생합니다. '인스턴스가 실패했습니다. 반환 코드 : 126 출력 :/bin/sh : .ebextensions/supervise.sh : 사용 권한이 거부되었습니다. '이 문제를 해결하기 위해 어떤 경험이 있습니까? – hackerman