简体   繁体   中英

AWS Database Migration Error while deploying ruby on rails app on Elastic Beanstalk Environment

As I'm trying to deploy my RoR app through AWS Elastic Beanstalk Environment, I'm getting the following error on the console :

ERROR: [Instance: i-0c1d25d2a182d8424] Command failed on instance. Return code: 1 Output: (TRUNCATED)...ly and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
/opt/rubies/ruby-2.5.0/bin/bundle:23:in `load'
/opt/rubies/ruby-2.5.0/bin/bundle:23:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace). 
Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/12_db_migration.sh failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
INFO: Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
ERROR: Unsuccessful command execution on instance id(s) 'i-0c1d25d2a182d8424'. Aborting the operation.
ERROR: Failed to deploy application.  

The following is my configuration in the database.yml

production:
  <<: *default
  database: <%= ENV['RDS_DB_NAME'] %>
  username: <%= ENV['RDS_USERNAME'] %>
  host: <%= ENV['RDS_HOSTNAME'] %>
  password: <%= ENV['RDS_PASSWORD'] %>
  port: <%= ENV['RDS_PORT'] %>

And the following is the error as reported on the log :

  ++ export RUBY_ROOT=/opt/rubies/ruby-2.5.0
  ++ RUBY_ROOT=/opt/rubies/ruby-2.5.0
  ++ export RUBYOPT=
  ++ RUBYOPT=
  ++ export PATH=/opt/rubies/ruby-2.5.0/bin:/opt/elasticbeanstalk/lib/ruby/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
  ++ PATH=/opt/rubies/ruby-2.5.0/bin:/opt/elasticbeanstalk/lib/ruby/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
  +++ /opt/rubies/ruby-2.5.0/bin/ruby -
  ++ eval 'export RUBY_ENGINE=ruby;
  export RUBY_VERSION=2.5.0;
  export GEM_ROOT="/opt/rubies/ruby-2.5.0/lib/ruby/gems/2.5.0";'
  +++ export RUBY_ENGINE=ruby
  +++ RUBY_ENGINE=ruby
  +++ export RUBY_VERSION=2.5.0
  +++ RUBY_VERSION=2.5.0
  +++ export GEM_ROOT=/opt/rubies/ruby-2.5.0/lib/ruby/gems/2.5.0
  +++ GEM_ROOT=/opt/rubies/ruby-2.5.0/lib/ruby/gems/2.5.0
  ++ ((  0 != 0  ))
  + cd /var/app/ondeck
  + su -s /bin/bash -c 'bundle exec /opt/elasticbeanstalk/support/scripts/check-for-rake-task.rb db:migrate' 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 'leader_only bundle exec rake db:migrate' webapp
  `/home/webapp` is not a directory.
  Bundler will use `/tmp/bundler/home/webapp' as your home directory temporarily.
  rake aborted!
  PG::ConnectionBad: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
  /opt/rubies/ruby-2.5.0/bin/bundle:23:in `load'
  /opt/rubies/ruby-2.5.0/bin/bundle:23:in `<main>'
  Tasks: TOP => db:migrate
  (See full trace by running task with --trace) (Executor::NonZeroExitStatus) 

Also, rake db:migrate works fine locally. I have no idea what could be going on here, for the database I tried to import a snapshot of an instance of the database I already had on AWS RDS, but I also tried to create a new database.

If you think if you have any idea of what could be hapening here, if would be really appreciated if you could let me know.

Thanks in advance.

As your comment, I believe that you missed configurate RDS_* in Elastic Beanstalk. To fix that:

  1. To configurate all RDS_*, please follow this guideline here: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environments-cfg-softwaresettings.html#environments-cfg-softwaresettings-console .
  2. Redeploy your application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM