如何在每次任务中运行一个capistrano任务?

问题描述:

我有whenever宝石安装正确。我如何运行capistrano从我的wheneverschedule.rb如何在每次任务中运行一个capistrano任务?

我schedule.rb

every 1.minute, roles: [:app] do 
    # how to run here a capistrano task 
    # invoke 'my_app:test' 
end 

我Capistrano的任务:

namespace :my_app do 

    desc 'test' 

    task :test do 
    on roles(:web) do 
     puts "the task runs" 
    end 
    end 
end 

或者我应该动议的任务变成了rake任务。我应该在whenevercapistrano范围内运行该耙子任务吗?

我会建议你的后一种选择,将逻辑移动到rake任务,并在每当和Capistrano执行它。这样做会更容易,更干净。