Ruby on rails 3 &引用;无法连接到服务器:没有这样的文件或目录";使用beanstalk部署Rails应用程序时
在使用Rails 3.2.17部署应用程序时,我们遇到以下错误 eb commandprocessor.logRuby on rails 3 &引用;无法连接到服务器:没有这样的文件或目录";使用beanstalk部署Rails应用程序时,ruby-on-rails-3,postgresql,amazon-web-services,deployment,amazon-elastic-beanstalk,Ruby On Rails 3,Postgresql,Amazon Web Services,Deployment,Amazon Elastic Beanstalk,在使用Rails 3.2.17部署应用程序时,我们遇到以下错误 eb commandprocessor.log + su -s /bin/bash -c 'leader_only bundle exec rake db:migrate' webapp rake aborted! could not connect to server: No such file or directory Is the server running locally and accepting con
+ su -s /bin/bash -c 'leader_only bundle exec rake db:migrate' webapp
rake aborted!
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"?
/var/app/ondeck/config/environment.rb:5:in `<top (required)>'
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace) (ElasticBeanstalk::ActivityFatalError)
at /opt/elasticbeanstalk/lib/ruby/lib/ruby/gems/2.1.0/gems/beanstalk-core-1.1/lib/elasticbeanstalk/activity.rb:189:in `rescue in exec'
...
caused by: command failed with error code 1: /opt/elasticbeanstalk/hooks/appdeploy/pre/12_db_migration.sh
令人惊讶的是,我们能够启动rails控制台,并且我们还验证了上述所有环境变量都返回了正确的值
还可以通过以下命令通过psql进行连接
psql-h RDS\U HOSTNAME-d RDS\U DB\U NAME-U RDS\U USERNAME
在我这方面,问题是因为我删除了我的。elasticbeanstalk/optionsettings
因此没有定义RACK\U ENV
,AWS默认情况下将其设置为production
,这导致我的应用程序具有错误的数据库主机名
我通过在
/opt/elasticbeanstalk/hooks/appdeploy/pre/12_db_migration.sh
中添加echo
语句来调试它,以显示RACK_ENV
,并注意到它是空的。我这里也有同样的问题,但Rails 4幸运地解决了吗?这里也有同样的问题。手动操作时也可以工作。正在做这件事。。。
production:
adapter: postgresql
database: <%= ENV['RDS_DB_NAME'] %>
username: <%= ENV['RDS_USERNAME'] %>
password: <%= ENV['RDS_PASSWORD'] %>
host: <%= ENV['RDS_HOSTNAME'] %>
port: <%= ENV['RDS_PORT'] %>