Thin / Capistrano无法连接到数据库

我正在尝试设置我的Ruby on Rails应用程序以部署到Thin集群。 当我使用bundle exec thin start -C config/thin.yml在服务器上手动启动瘦集群时,一切正常。 但是当我通过Capistrano运行相同的命令时,它就会死掉并显示日志:

/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract/connection_specification.rb:45:in `resolve_hash_connection': database configuration does not specify adapter (ActiveRecord::AdapterNotSpecified)

我很茫然,我使用capistrano脚本中定义的相同用户帐户登录服务器。

我的capistrano瘦任务:

  namespace :deploy do task :start do run "cd #{current_path}; bundle exec thin start -C config/thin.yml" end task :stop do run "cd #{current_path}; bundle exec thin stop -C config/thin.yml" end task :restart do run "cd #{current_path}; bundle exec thin restart -C config/thin.yml" end end 

这是我的thin.yml:

 --- chdir: /var/www/rails/myapp/current environment: staging address: 0.0.0.0 port: 3000 timeout: 30 log: log/thin.log pid: tmp/pids/thin.pid max_conns: 1024 max_persistent_conns: 512 require: [] wait: 30 servers: 2 daemonize: true 

任何帮助,将不胜感激

我需要在每一步上明确设置RAILS_ENV。

run "cd #{current_path}; RAILS_ENV=#{rails_env} bundle exec thin start -C config/thin.yml"

似乎Capistrano没有拿起我们的环境变量

这是一篇相关的post:

如何在我的linux系统下为每个人设置环境变量?