加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – Capistrano 3,Rails 4,数据库配置不指定适配器

发布时间:2020-12-16 20:48:26 所属栏目:百科 来源:网络整理
导读:当我开始 cap production deploy 它失败了这样: 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
当我开始

cap production deploy

它失败了这样:

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,'git@github.com: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,但这看起来像我的硬编码,我相信有一个更好的解决方案.

解决方法

编辑:每 this pull request,它现在修复在1.1.0的capistrano-rails.

每个this Github issue,另一个修复是编辑您的Capfile.评论这两行

#require 'capistrano/rails/assets'
#require 'capistrano/rails/migrations'

并把这一行放进去

require 'capistrano/rails'

这将正确设置您的RAILS_ENV变量.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读