当我尝试通过AWS Elastic Beanstalk环境部署我的RoR应用程序时,我在控制台上收到以下错误:
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.
以下是我在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'] %>
以下是日志中报告的错误:
++ 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)
此外,rake db:migrate在本地工作正常。我不知道这里会发生什么,对于数据库我试图导入我在AWS RDS上已经拥有的数据库实例的快照,但我也试图创建一个新的数据库。
如果你认为如果你知道在这里可能会有什么影响,如果你能让我知道的话,我真的很感激。
提前致谢。
答案 0 :(得分:0)
作为您的评论,我相信您错过了Elastic Beanstalk中的配置RDS_ *。解决这个问题: