當我開始Capistrano的3,軌道4,數據庫配置不指定適配器
帽生產部署
失敗是這樣的:
DEBUG [4ee8fa7a] Command: cd /home/deploy/myapp/releases/releases/20131025212110 && (RVM_BIN_PATH=~/.rvm/bin RAILS_ENV= ~/.rvm/bin/myapp_rake assets:precompile)
DEBUG [4ee8fa7a] rake aborted!
DEBUG [4ee8fa7a] database configuration does not specify adapter
你可以看到「 RAILS_ENV =「實際上是空的,我想知道爲什麼會發生這種情況?我認爲這是後一個錯誤的原因,我沒有數據庫配置。
的deploy.rb文件如下:
set :application, 'myapp'
set :repo_url, '[email protected]:developer/myapp.git'
set :branch, :master
set :deploy_to, '/home/deploy/myapp/releases'
set :scm, :git
set :devpath, "/home/deploy/myapp_development"
set :user, "deploy"
set :use_sudo, false
set :default_env, { rvm_bin_path: '~/.rvm/bin' }
set :keep_releases, 5
namespace :deploy do
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
# Your restart mechanism here, for example:
within release_path do
execute " bundle exec thin restart -O -C config/thin/production.yml"
end
end
end
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
within release_path do
end
end
end
after :finishing, 'deploy:cleanup'
end
的database.yml:
production:
adapter: mysql2
encoding: utf8
database: myapp_production
pool: 5
username: user
password: pass
host: localhost
development:
adapter: mysql2
encoding: utf8
database: myapp_development
pool: 5
username: user
password: pass
host: localhost
的問題解決了,如果我添加
set :rails_env, "production"
我deploy.rb,但是這看起來像我硬編碼,我相信有一個更好的解決方案。
你可以發佈你的'database.yml'嗎?它應該包含數據庫適配器的「生產」部分。 –
我將它添加到描述中。 – Kazmin
如果'gem「mysql2」'聲明在'group:production do ... end'內,我建議再檢查一下'Gemfile'。 –