这是我的第一个铁轨项目,与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, 'ruby-1.9.3-p194@xxx' # 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, "git@xx.beanstalkapp.com:/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 1.9.3@ac_helenefrance_01 ruby-1.9.3-p194@#{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
被破坏的原因的任何帮助都会非常有帮助。
谢谢。
答案 0 :(得分:4)
您忘记了 s ,如cap deploy:migrations