池大小没有产生足够的进程

时间:2019-06-06 02:15:22

标签: ruby amazon-web-services passenger amazon-elastic-beanstalk

我正在运行Passenger with Ruby 2.5 running on 64bit Amazon Linux/2.9.3,并且尝试通过命令行传递参数以增加--min-instances--max-pool-size

执行此操作的代码如下一行

GENERALOPTS="-p $EB_HTTP_PORT --pid-file $EB_APP_PID_DIR/passenger.pid --min-instances=${PASSENGER_MIN_POOL_SIZE:-6} --max-pool-size=${PASSENGER_MAX_POOL_SIZE:-6}"

我的PASSENGER_MIN_POOL_SIZEPASSENGER_MAX_POOL_SIZE的环境变量值设置为50

我面临的问题是由于某种原因它只会生成36个进程而不是50个进程。我在做什么错了?

这是我的完整配置文件

files:
  "/tmp/passenger.config":
    mode: "000755"
    owner: root
    group: root
    content: |
      #!/usr/bin/env bash
      #
      # chkconfig: 2345 80 20
      # description: Passenger
      #

      EB_HTTP_PORT=$(/opt/elasticbeanstalk/bin/get-config container -k http_port)
      EB_APP_USER=$(/opt/elasticbeanstalk/bin/get-config container -k app_user)
      EB_APP_DEPLOY_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_deploy_dir)
      EB_APP_PID_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_pid_dir)
      EB_APP_LOG_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_log_dir)
      EB_SCRIPT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k script_dir)
      EB_SUPPORT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k support_dir)
      EB_NGINX_VERSION=$(/opt/elasticbeanstalk/bin/get-config container -k nginx_version)

      . $EB_SUPPORT_DIR/envvars
      . $EB_SCRIPT_DIR/use-app-ruby.sh

      if [ -f /etc/elasticbeanstalk/set-ulimit.sh ]; then
        . /etc/elasticbeanstalk/set-ulimit.sh
      fi

      # fixes http://code.google.com/p/phusion-passenger/issues/detail?id=614
      export HOME=/tmp
      export PASSENGER_DOWNLOAD_NATIVE_SUPPORT_BINARY=0

      if [ -d /etc/healthd ]; then
          STARTOPTS="--nginx-version $EB_NGINX_VERSION --nginx-config-template $EB_SUPPORT_DIR/conf/nginx_config_healthd.erb"
      else
          STARTOPTS="--nginx-version $EB_NGINX_VERSION --nginx-config-template $EB_SUPPORT_DIR/conf/nginx_config.erb"
      fi

      ENV_STAGE=${RACK_ENV:-$RAILS_ENV}    # Read from $RAILS_ENV if $RACK_ENV is empty
      if [ ${ENV_STAGE,,} = "production" ]; then    # Convert $ENV_STAGE to lower case and compare to "production"
        # Disable passenger friendly page for production stage
        STARTOPTS="$STARTOPTS --no-friendly-error-pages"
      fi

      GENERALOPTS="-p $EB_HTTP_PORT --pid-file $EB_APP_PID_DIR/passenger.pid --min-instances=${PASSENGER_MIN_POOL_SIZE:-6} --max-pool-size=${PASSENGER_MAX_POOL_SIZE:-6}"

      function start() {
        touch $EB_APP_LOG_DIR/passenger.log

        if [ -d /etc/healthd ]; then
          mkdir -p $EB_APP_LOG_DIR/healthd
          chown -R $EB_APP_USER:$EB_APP_USER $EB_APP_LOG_DIR/healthd
        fi

        chown $EB_APP_USER:$EB_APP_USER \
          $EB_APP_LOG_DIR/passenger.log
        passenger start $EB_APP_DEPLOY_DIR $STARTOPTS $GENERALOPTS \
          -d -e ${RACK_ENV:-$RAILS_ENV} --user $EB_APP_USER \
          --log-file $EB_APP_LOG_DIR/passenger.log
      }

      function stop() {
        passenger stop $GENERALOPTS
      }

      function status() {
        passenger status $GENERALOPTS
      }

      case "$1" in
        start)
          start
          ;;
        stop)
          stop
          ;;
        status)
          status
          ;;
        restart|graceful)
          stop
          start
          ;;
        reload)
          su -s /bin/bash -c "touch $EB_APP_DEPLOY_DIR/tmp/restart.txt" $EB_APP_USER
          ;;
        *)
          echo "Usage: $0 {start|stop|restart|reload|status}"
          exit 1
          ;;
      esac

      exit 0

container_commands:
  01_config_passenger:
    command: "cp /tmp/passenger.config /opt/elasticbeanstalk/support/conf/passenger"

1 个答案:

答案 0 :(得分:0)

我有类似的问题和配置,但是--max-pool-size也不是/etc/init.d/passenger stop/etc/init.d/passenger restart的可用选项,因为我正在获得

enter image description here

因此,我仅将--max-pool-size$GENERALOPTS移到了start命令。您应该有类似

(...)
passenger start $EB_APP_DEPLOY_DIR $STARTOPTS $GENERALOPTS \
 --min-instances=${PASSENGER_MIN_POOL_SIZE:-6} \
 --max-pool-size=${PASSENGER_MAX_POOL_SIZE:-6} \
 -d -e ${RACK_ENV:-$RAILS_ENV} --user $EB_APP_USER \
(...)

那对我来说是一种魅力!