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 スクリプトで定義されているのと同じユーザー アカウントを使用してサーバーにログインします。

マイ カピストラーノ シン タスク:

  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 に答える