开发者

How do you add some steps to a capistrano task?

I开发者_StackOverflow中文版'd like to stop some processes before running the deploy:migrate task. I know that I can redefine the deploy:migrate task by copying the existing code and adding the stop/start steps at the beginning and end of the task.

I'm wondering if there is a way to avoid copying the code from the default deploy:migrate task in my version of the task. Is there a way to refer to the existing deploy:migrate task when defining a new task of the same name?


Rather than redefining deploy:migrate, you should define a before or after hook for it. First, create a new task that does the stuff you need to do:

task :custom_name do
  # whatever you need to do
end

And then set this new task to be run before or after the deploy:migrate task by doing one of the following:

before "deploy:migrate", :custom_name
after "deploy:migrate", :custom_name


For my requirements, I override the existing task in deploy.rb

namespace :deploy do
  # to Override deploy:migrate task
  task :precompile, :roles => :app, :except => { :no_release => true } do
    run "your modified commands"
  end
  # to override deploy:assets:precompile task
  namespace :assets do
    task :precompile, :roles => :app, :except => { :no_release => true } do
      run "your modified commands"
    end
  end
end
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜