Ruby   发布时间:2022-04-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ruby-on-rails – 部署时Capistrano 3不运行rails迁移大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我想将一个应用程序部署到我的本地服务器.我正在使用capistrano 3.

这是我的capfile

require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rvm'
require 'capistrano/bundler'
require 'capistrano/rails'
#require 'capistrano/rails/migrations'
#require 'capistrano/rails/assets'


# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }

这是我的deploy.rb

# config valid only for Capistrano 3.1
lock '3.1.0'

set :application,'ImpresaZiliani'
set :repo_url,'francesco@10.0.1.8:repos/impresaziliani.git'
set :branch,'master'
# Default branch is :master
# ask :branch,proc { `git rev-parse --abbrev-ref HEAD`.chomp }

# Default deploy_to directory is /var/www/my_app
set :deploy_to,'/home/francesco/impresaziliani'

# Default value for :scm is :git
set :scm,:git
set :deploy_user,"francesco"
set :rails_env,"production"

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:
      # execute :touch,release_path.join('tmp/restart.txt')
    end
  end

  after :publishing,:restart

  after :restart,:clear_cache do
    on roles(:web),in: :groups,limit: 3,wait: 10 do
      # Here we can do anything such as:
      # within release_path do
      #   execute :rake,'cache:clear'
      # end
   end
  end

end

set :rvm_ruby_version,'2.1.1'
set :default_env,{ rvm_bin_path: '~/.rvm/bin' }
SSHKit.config.command_map[:rake] = "#{fetch(:default_env)[:rvm_bin_path]}/rvm ruby-#                   {fetch(:rvm_ruby_version)} do bundle exec rake"

我的database.yml是好的,因为如果我手动运行服务器上的迁移工作,我已经尝试取消注释capistrano / rails /迁移和资产的行,但没有任何改变:当我部署它运行良好,直到捆绑安装,然后没有任何警告或错误,跳到资产预编译器,并且不运行迁移.

我如何解决这个问题?

谢谢

解决方法

rake db:migrate在capistrano 3中自动部署 您只需要在Capfile中取消注释#require’capistrano / rails / migrations’

大佬总结

以上是大佬教程为你收集整理的ruby-on-rails – 部署时Capistrano 3不运行rails迁移全部内容,希望文章能够帮你解决ruby-on-rails – 部署时Capistrano 3不运行rails迁移所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。