1

탄력있는 beanstalk를 사용하여 코드를 AWS에 배포하려고하지만 배포시 오류가 계속 발생합니다.rb-readline로 인해 Elastic Beanstalk을 사용하여 AWS에 레일 5 응용 프로그램을 배포하는 문제가 발생했습니다.

'rb-readline'을 추가했으며 로그를 확인할 때 배포시이 보석에 오류가 있음을 확인했습니다. gem 'rb-readline'을 추가 할 때 오류가 있었는지 기억이 나지 않지만 보석을 지우면이 문제가 해결 될지 모르겠습니다. 다음은 보석에 대한 링크입니다. https://github.com/ConnorAtherton/rb-readline

여기에 배치 된 오류 로그가 있습니다.

Application update failed at 2017-10-24T19:27:36Z with exit status 1 and error: Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/11_asset_compilation.sh failed. 

++ /opt/elasticbeanstalk/bin/get-config container -k script_dir 
+ EB_SCRIPT_DIR=/opt/elasticbeanstalk/support/scripts 
++ /opt/elasticbeanstalk/bin/get-config container -k app_staging_dir 
+ EB_APP_STAGING_DIR=/var/app/ondeck 
++ /opt/elasticbeanstalk/bin/get-config container -k app_user 
+ EB_APP_USER=webapp 
++ /opt/elasticbeanstalk/bin/get-config container -k support_dir 
+ EB_SUPPORT_DIR=/opt/elasticbeanstalk/support 
+ . /opt/elasticbeanstalk/support/envvars 
++ export RACK_ENV=production 
++ RACK_ENV=production 
++ export RAILS_SKIP_ASSET_COMPILATION=false 
++ RAILS_SKIP_ASSET_COMPILATION=false 
++ export RAILS_SKIP_MIGRATIONS=false 
++ RAILS_SKIP_MIGRATIONS=false 
++ export BUNDLE_WITHOUT=test:development 
++ BUNDLE_WITHOUT=test:development 
++ export RDS_PORT=5432 
++ RDS_PORT=5432 
++ export RDS_HOSTNAME=aa16lalntiz6vr0.cghvpjf0tzo5.us-east-1.rds.amazonaws.com 
++ RDS_HOSTNAME=aa16lalntiz6vr0.cghvpjf0tzo5.us-east-1.rds.amazonaws.com 
++ export RDS_USERNAME=theasteve 
++ RDS_USERNAME=theasteve 
++ export RDS_DB_NAME=ebdb 
++ RDS_DB_NAME=ebdb 
++ export RDS_PASSWORD=Colombia1 
++ RDS_PASSWORD=Colombia1 
+ RAKE_TASK=assets:precompile 
+ . /opt/elasticbeanstalk/support/scripts/use-app-ruby.sh 
++ . /usr/local/share/chruby/chruby.sh 
+++ CHRUBY_VERSION=0.3.9 
+++ 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-p648 
ruby-2.1.10 
ruby-2.2.8 
ruby-2.3.5 
ruby-2.4.2 
ruby-current ]] 
+++ RUBIES+=("$dir"/*) 
+++ for dir in '"$PREFIX/opt/rubies"' '"$HOME/.rubies"' 
+++ [[ -d /.rubies ]] 
+++ unset dir 
+++ cat /etc/elasticbeanstalk/.ruby_version 
++ chruby 2.3.5 
++ case "$1" in 
++ local dir match 
++ for dir in '"${RUBIES[@]}"' 
++ dir=/opt/rubies/ruby-1.9.3-p551 
++ case "${dir##*/}" in 
++ for dir in '"${RUBIES[@]}"' 
++ dir=/opt/rubies/ruby-2.0.0-p648 
++ case "${dir##*/}" in 
++ for dir in '"${RUBIES[@]}"' 
++ dir=/opt/rubies/ruby-2.1.10 
++ case "${dir##*/}" in 
++ for dir in '"${RUBIES[@]}"' 
++ dir=/opt/rubies/ruby-2.2.8 
++ case "${dir##*/}" in 
++ for dir in '"${RUBIES[@]}"' 
++ dir=/opt/rubies/ruby-2.3.5 
++ case "${dir##*/}" in 
++ match=/opt/rubies/ruby-2.3.5 
++ for dir in '"${RUBIES[@]}"' 
++ dir=/opt/rubies/ruby-2.4.2 
++ case "${dir##*/}" in 
++ for dir in '"${RUBIES[@]}"' 
++ dir=/opt/rubies/ruby-current 
++ case "${dir##*/}" in 
++ [[ -z /opt/rubies/ruby-2.3.5 ]] 
++ shift 
++ chruby_use /opt/rubies/ruby-2.3.5 '' 
++ [[ ! -x /opt/rubies/ruby-2.3.5/bin/ruby ]] 
++ [[ -n '' ]] 
++ export RUBY_ROOT=/opt/rubies/ruby-2.3.5 
++ RUBY_ROOT=/opt/rubies/ruby-2.3.5 
++ export RUBYOPT= 
++ RUBYOPT= 
++ export PATH=/opt/rubies/ruby-2.3.5/bin:/opt/elasticbeanstalk/lib/ruby/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin 
++ PATH=/opt/rubies/ruby-2.3.5/bin:/opt/elasticbeanstalk/lib/ruby/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin 
+++ /opt/rubies/ruby-2.3.5/bin/ruby - 
++ eval 'export RUBY_ENGINE=ruby; 
export RUBY_VERSION=2.3.5; 
export GEM_ROOT="/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0";' 
+++ export RUBY_ENGINE=ruby 
+++ RUBY_ENGINE=ruby 
+++ export RUBY_VERSION=2.3.5 
+++ RUBY_VERSION=2.3.5 
+++ export GEM_ROOT=/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0 
+++ GEM_ROOT=/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.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 
`/home/webapp` is not a directory. 
Bundler will use `/tmp/bundler/home/webapp' as your home directory temporarily. 
+ '[' false == true ']' 
+ su -s /bin/bash -c 'bundle exec rake assets:precompile' webapp 
`/home/webapp` is not a directory. 
Bundler will use `/tmp/bundler/home/webapp' as your home directory temporarily. 
rake aborted! 
Bundler::GemRequireError: There was an error while trying to load the gem 'rb-readline'. 
Gem Load Error is: HOME environment variable (or HOMEDRIVE and HOMEPATH) must be set and point to a directory 
Backtrace for gem load error is: 
/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0/gems/rb-readline-0.5.4/lib/rbreadline.rb:1097:in `<module:RbReadline>' 
/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0/gems/rb-readline-0.5.4/lib/rbreadline.rb:17:in `<top (required)>' 
/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0/gems/rb-readline-0.5.4/lib/readline.rb:10:in `require' 
/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0/gems/rb-readline-0.5.4/lib/readline.rb:10:in `<module:Readline>' 
/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0/gems/rb-readline-0.5.4/lib/readline.rb:8:in `<top (required)>' 
/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0/gems/rb-readline-0.5.4/lib/rb-readline.rb:16:in `require' 
/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0/gems/rb-readline-0.5.4/lib/rb-readline.rb:16:in `<top (required)>' 
/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/runtime.rb:82:in `require' 
/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/runtime.rb:82:in `block (2 levels) in require' 
/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/runtime.rb:77:in `each' 
/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/runtime.rb:77:in `block in require' 
/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/runtime.rb:66:in `each' 
/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/runtime.rb:66:in `require' 
/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler.rb:108:in `require' 
/var/app/ondeck/config/application.rb:17:in `<top (required)>' 
/var/app/ondeck/Rakefile:4:in `require_relative' 
/var/app/ondeck/Rakefile:4:in `<top (required)>' 
/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/rake_module.rb:28:in `load' 
/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/rake_module.rb:28:in `load_rakefile' 
/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:687:in `raw_load_rakefile' 
/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:96:in `block in load_rakefile' 
/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:178:in `standard_exception_handling' 
/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:95:in `load_rakefile' 
/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:79:in `block in run' 
/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:178:in `standard_exception_handling' 
/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:77:in `run' 
/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>' 
/opt/rubies/ruby-2.3.5/bin/rake:23:in `load' 
/opt/rubies/ruby-2.3.5/bin/rake:23:in `<top (required)>' 
/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/cli/exec.rb:74:in `load' 
/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/cli/exec.rb:74:in `kernel_load' 
/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/cli/exec.rb:27:in `run' 
/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/cli.rb:360:in `exec' 
/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run' 
/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command' 
/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/vendor/thor/lib/thor.rb:369:in `dispatch' 
/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/cli.rb:20:in `dispatch' 
/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/vendor/thor/lib/thor/base.rb:444:in `start' 
/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/cli.rb:10:in `start' 
/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/exe/bundle:35:in `block in <top (required)>' 
/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/lib/bundler/friendly_errors.rb:121:in `with_friendly_errors' 
/opt/rubies/ruby-2.3.5/lib/ruby/gems/2.3.0/gems/bundler-1.15.0/exe/bundle:27:in `<top (required)>' 
/opt/rubies/ruby-2.3.5/bin/bundle:23:in `load' 
/opt/rubies/ruby-2.3.5/bin/bundle:23:in `<main>' 
Bundler Error Backtrace: 
/var/app/ondeck/config/application.rb:17:in `<top (required)>' 
/var/app/ondeck/Rakefile:4:in `require_relative' 
/var/app/ondeck/Rakefile:4:in `<top (required)>' 
/opt/rubies/ruby-2.3.5/bin/bundle:23:in `load' 
/opt/rubies/ruby-2.3.5/bin/bundle:23:in `<main>' 
HOME environment variable (or HOMEDRIVE and HOMEPATH) must be set and point to a directory 
/var/app/ondeck/config/application.rb:17:in `<top (required)>' 
/var/app/ondeck/Rakefile:4:in `require_relative' 
/var/app/ondeck/Rakefile:4:in `<top (required)>' 
/opt/rubies/ruby-2.3.5/bin/bundle:23:in `load' 
/opt/rubies/ruby-2.3.5/bin/bundle:23:in `<main>' 
(See full trace by running task with --trace). 
Incorrect application version "app-cd09-171024_152653" (deployment 3). Expected version "app-cd09-171024_150253" (deployment 2). 
100 % of CPU is in use. 

답변

1

나는 유사한 오류가 있었지만 dot-env rails gem이 있습니다. 일 수도 있고과 같은 근본 원인이 될 수 있습니다.

배포 도중 $HOME이 AWS에 의해 설정되지 않았고 File.expand_path에 대한 호출이 설정되지 않았기 때문에 발생하는 것으로 보입니다.

가능한 수정 :

  1. 제거 rbreadline
  2. 스크립트 &는 $를 추가하여 EB 구성 또는 eb setenvHOME 환경 변수를 추가 (및 재배치)
  3. 가 배포 기존 덮어 설정 파일을 추가 번들 설치 명령을 실행하기 전에 HOME 변수 (/opt/elasticbeanstalk/appdeploy/hooks/pre/ 폴더 IIRC)

첫 번째와 마지막 옵션을 성공적으로 시도한 결과, 누락 된 $HOME을 올바르게 처리 한 Gem의 분기 된 버전을 사용하여 해결되었습니다.

두 번째 버전이 더 정확한 방법이라고 생각합니다. Amazon이 $HOME을 시작하도록 설정하지 않은 이유와 실제로 무엇을해야하는지 명확하지 않습니다.

앱은 /var/app/ondeck 또는 /var/app/current 중 하나이므로이 두 폴더 중 하나 (오류 당 /home/webapp)가 모두 좋은 값일 수 있습니다.

다른 버전의 Ruby에서 로컬로 복제 할 때 행운을 바꿨 기 때문에 100 % 근원이 아닐 수도 있습니다. 그러나 expand_path 문서는 HOME이 올바르게 설정되어야한다고 말합니다. 원인이 될 수 있습니다.

https://ruby-doc.org/core-2.4.2/File.html#method-c-expand_path