创建新的Elastic Beanstalk工作线程

时间:2016-03-04 17:32:09

标签: ruby-on-rails ruby amazon-web-services bundler elastic-beanstalk

第一次来电,长时间听众。我在AWS Elastic Beanstalk Web服务器环境中运行了一个没有问题的rails应用程序,现在我想将类似的应用程序部署到工作线程环境,以对上传文件进行异步处理。就目前而言,为了实现这一目标,我正在将相同版本的应用程序(换句话说,在多个Web服务器环境中运行良好的版本)部署到工作环境(使用与Web服务器环境相同的平台) ,但是当它尝试执行初始rake assets:precompile时,我得到一个RubyVersionMismatch:

$ tail -n 100 /var/log/eb-activity.log

  + RAKE_TASK=assets:precompile
  + . /opt/elasticbeanstalk/support/scripts/use-app-ruby.sh
  ++ . /usr/local/share/chruby/chruby.sh
  +++ CHRUBY_VERSION=0.3.8
  +++ RUBIES=()
  +++ for dir in '"$PREFIX/opt/rubies"' '"$HOME/.rubies"'
  +++ [[ -d /opt/rubies ]]
  ++++ ls -A /opt/rubies
  +++ [[ -n ruby-1.9.3-p551
  ruby-2.0.0-p598
  ruby-2.1.5
  ruby-2.2.2
  ruby-current ]]
  +++ RUBIES+=("$dir"/*)
  +++ for dir in '"$PREFIX/opt/rubies"' '"$HOME/.rubies"'
  +++ [[ -d /.rubies ]]
  +++ unset dir
  +++ cat /etc/elasticbeanstalk/.ruby_version
  ++ chruby 2.2.2
  ++ case "$1" in
  ++ local dir match
  ++ for dir in '"${RUBIES[@]}"'
  ++ dir=/opt/rubies/ruby-1.9.3-p551
  ++ [[ ruby-1.9.3-p551 == *\2\.\2\.\2* ]]
  ++ for dir in '"${RUBIES[@]}"'
  ++ dir=/opt/rubies/ruby-2.0.0-p598
  ++ [[ ruby-2.0.0-p598 == *\2\.\2\.\2* ]]
  ++ for dir in '"${RUBIES[@]}"'
  ++ dir=/opt/rubies/ruby-2.1.5
  ++ [[ ruby-2.1.5 == *\2\.\2\.\2* ]]
  ++ for dir in '"${RUBIES[@]}"'
  ++ dir=/opt/rubies/ruby-2.2.2
  ++ [[ ruby-2.2.2 == *\2\.\2\.\2* ]]
  ++ match=/opt/rubies/ruby-2.2.2
  ++ for dir in '"${RUBIES[@]}"'
  ++ dir=/opt/rubies/ruby-current
  ++ [[ ruby-current == *\2\.\2\.\2* ]]
  ++ [[ -z /opt/rubies/ruby-2.2.2 ]]
  ++ shift
  ++ chruby_use /opt/rubies/ruby-2.2.2 ''
  ++ [[ ! -x /opt/rubies/ruby-2.2.2/bin/ruby ]]
  ++ [[ -n '' ]]
  ++ export RUBY_ROOT=/opt/rubies/ruby-2.2.2
  ++ RUBY_ROOT=/opt/rubies/ruby-2.2.2
  ++ export RUBYOPT=
  ++ RUBYOPT=
  ++ export PATH=/opt/rubies/ruby-2.2.2/bin:/opt/elasticbeanstalk/lib/ruby/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
  ++ PATH=/opt/rubies/ruby-2.2.2/bin:/opt/elasticbeanstalk/lib/ruby/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
  +++ /opt/rubies/ruby-2.2.2/bin/ruby -
  ++ eval 'export RUBY_ENGINE=ruby;
  export RUBY_VERSION=2.2.2;
  export GEM_ROOT="/opt/rubies/ruby-2.2.2/lib/ruby/gems/2.2.0";'
  +++ export RUBY_ENGINE=ruby
  +++ RUBY_ENGINE=ruby
  +++ export RUBY_VERSION=2.2.2
  +++ RUBY_VERSION=2.2.2
  +++ export GEM_ROOT=/opt/rubies/ruby-2.2.2/lib/ruby/gems/2.2.0
  +++ GEM_ROOT=/opt/rubies/ruby-2.2.2/lib/ruby/gems/2.2.0
  ++ ((  0 != 0  ))
  + cd /var/app/ondeck
  + su -s /bin/bash -c 'bundle exec /opt/elasticbeanstalk/support/scripts/check-for-rake-task.rb assets:precompile' webapp
  + '[' false == true ']'
  + su -s /bin/bash -c 'bundle exec rake assets:precompile' webapp
/opt/rubies/ruby-2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.9.6/lib/bundler/definition.rb:379:in `validate_ruby!': Your Ruby version is 2.1.5, but your Gemfile specified 2.2.2 (Bundler::RubyVersionMismatch)
from /opt/rubies/ruby-2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.9.6/lib/bundler.rb:118:in `setup'
from /opt/rubies/ruby-2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.9.6/lib/bundler/setup.rb:18:in `<top (required)>'
from /opt/elasticbeanstalk/lib/ruby/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /opt/elasticbeanstalk/lib/ruby/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require' (Executor::NonZeroExitStatus)


[2016-03-04T15:28:08.146Z] INFO  [1693]  - [CMD-Startup/StartupStage0/AppDeployPreHook/11_asset_compilation.sh] : Activity failed.
[2016-03-04T15:28:08.147Z] INFO  [1693]  - [CMD-Startup/StartupStage0/AppDeployPreHook] : Activity failed.
[2016-03-04T15:28:08.147Z] INFO  [1693]  - [CMD-Startup/StartupStage0] : Activity failed.
[2016-03-04T15:28:08.147Z] INFO  [1693]  - [CMD-Startup] : Completed activity. Result:
  Command CMD-Startup failed.

我的Gemfile确实调用了v2.2.2,但是如果你注意到,堆栈跟踪的底部两行显示正在调用的ruby存在于/ opt / elasticbeanstalk中,尽管chruby正确地找到了并从/ opt / rubies / ruby​​-current中选择版本2.2.2。任何想法为什么会这样?如果EB将随机回归到自己的本地版本,那么基于containerconfig动态选择ruby版本有什么意义呢?

1 个答案:

答案 0 :(得分:-1)

我不确定您是否对移动平台开放,但是您是否考虑过使用docker? (https://www.docker.com