2012-06-08 115 views
0

這是我的第一個鐵軌項目,它與Capistrano合作非常愉快。capistrano部署:遷移不存在

我目前的問題是我需要運行cap deploy:migrate和cap:deploy:migration作爲單獨的任務。我相信應該有一個帽子部署:遷移結合這些。

這裏是我的終端輸出:

kris$ cap staging deploy:migration 
     triggering load callbacks 
    * executing `staging' 
    the task `deploy:migration' does not exist 

我的設置是採用多階段和使用RVM Capistrano的插件。

這裏是我的寶石文件:

source 'https://rubygems.org' 

gem 'rails', '3.2.1' 

group :development do 
    gem 'sqlite3' 
end 

group :production do 
    gem 'mysql2' 
end 

group :test do 
    gem 'sqlite3' 
    gem 'ZenTest' 
end 

# Gems used only for assets and not required 
# in production environments by default. 
group :assets do 
    gem 'sass-rails', '~> 3.2.3' 
    gem 'coffee-rails', '~> 3.2.1' 
    gem 'uglifier', '>= 1.0.3' 
end 

#formtastic 2.2 breaks activeadmin 
gem "formtastic", "~> 2.1.1" 
gem "activeadmin", "~> 0.4.3" 

# meta_search required for activeadmin 
gem 'meta_search' 

gem 'jquery-rails' 
gem "paperclip", "~> 3.0" 

gem 'acts_as_list' 
gem 'unicorn' 

# Deploy with Capistrano 
gem 'capistrano' 
gem 'rvm-capistrano' 

gem 'mail' 
gem 'friendly_id' 

,這裏是我的配置/部署文件:

set :rvm_ruby_string, '[email protected]'      # Or: 
#set :rvm_ruby_string, ENV['GEM_HOME'].gsub(/.*\//,"") # Read from local system 

require "rvm/capistrano"        # Load RVM's capistrano plugin. 
require "bundler/capistrano" 

# set :verbose ,1 

require 'capistrano/ext/multistage' 
set :stages, %w(staging production) 
set :default_stage, "staging" 
set :deploy_via, :remote_cache 

set :user, "webm" 
# set :deploy_via, :remote_cache 
set :use_sudo, false 

set :scm, "git" 
set :repository, "[email protected]:/xx.git" 

# :branch is being set in stage files 

default_run_options[:pty] = true 
# ssh_options[:forward_agent] = true 

after "deploy", "deploy:cleanup" # keep only the last 5 releases 

namespace :deploy do 
    %w[start stop restart].each do |command| 
     desc "#{command} unicorn server" 
     task command, roles: :app, except: {no_release: true} do 
      run "#{sudo} service unicorn_#{server_configuration} #{command}" 
     end 
    end 

    desc "build missing paperclip styles" 
    task :build_missing_paperclip_styles, :roles=> :app do 
     run "cd #{release_path}; RAILS_ENV=production bundle exec rake paperclip:refresh:missing_styles" 
    end 
    after "deploy:update", "deploy:build_missing_paperclip_styles" 

    task :setup_config, roles: :app do 
     puts "#making symlink to nginx sites-enabled" 
     run "#{sudo} ln -fs #{current_path}/config/server/#{server_configuration}/nginx.conf /etc/nginx/sites-enabled/#{server_configuration}" 
     puts "#making symlink to unicorn service script" 
     run "#{sudo} ln -fs #{current_path}/config/server/#{server_configuration}/unicorn_init.sh /etc/init.d/unicorn_#{server_configuration}" 
     puts "#making a the new config directory" 
     run "mkdir -p #{shared_path}/config" 
     run "sunique 1" 
     put File.read("config/database.yml"), "#{shared_path}/config/database.yml" 
     run "sunique 0" 
     puts "Now edit the config files in #{shared_path}." 
    end 
    after "deploy:setup", "deploy:setup_config" 

    task :symlink_config, roles: :app do 
     run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml" 

     puts "#for reference:" 
     puts "#rvm wrapper [email protected]_helenefrance_01 [email protected]#{server_configuration} unicorn cap" 
     puts "#now be sure to run: sudo update-rc.d unicorn_#{server_configuration} defaults" 
    end 
    after "deploy:finalize_update", "deploy:symlink_config" 

    # desc "Make sure local git is in sync with remote." 
    # task :check_revision, roles: :web do 
     # if :isRemote == false 
      # unless `git rev-parse HEAD` == `git rev-parse beanstalk/#{branch}` 
       # puts "WARNING: HEAD is not the same as beanstalk/#{branch}" 
       # puts "Run `git push` to sync changes." 
       # exit 
      # end 
     # end 
    # end 
    #before "deploy", "deploy:check_revision" 
end 

與爲什麼deploy:migration被打破將是非常有益的幫助。 謝謝。

+1

結帳帽-T查看可用帽任務 –

+0

這是一個很好的提示。謝謝。 – LessQuesar

回答

4

你忘了小號,如cap deploy:migrations

+0

錯字!?!你是對的,非常感謝。 – LessQuesar