1

我正在尝试设置我的 Ruby on Rails 应用程序以部署到瘦集群。当我在服务器上手动启动瘦集群时,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 Thin 任务:

  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

任何帮助,将不胜感激

4

1 回答 1

0

我需要在每一步显式设置 RAILS_ENV。

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

Capistrano 似乎没有选择我们的环境变量

这是一个相关的帖子:

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

于 2012-07-27T18:17:40.800 回答