2013-01-22 110 views
2

我在使用時/ capistrano更新我的cron_tab與capistrano部署時,直到最近我的部署工作良好,直到最近我的部署在更新cron_tab時開始失敗。每當/ capistrano`method_missing_with_variables':未定義方法`role_names_for_host'

.rvm/gems/[email protected]/gems/capistrano-2.8.0/lib/capistrano/configuration/variables.rb:122:in `method_missing_with_variables': undefined method `role_names_for_host' for #<Capistrano::Configuration:0x000000018e6a10> (NoMethodError) 

我設置* role_names_for_host *

set_default(:whenever_roles, [:workers]) 

,我的任務是這樣的

namespace :whenever do 
    desc "Stop whenever" 
    task :stop , roles: [:workers] do 
    clear_crontab 
    end 

    desc "Start whenever" 
    task :start , roles: [:workers] do 
    update_crontab 
    end 

    desc "Restart whenever" 
    task :restart , roles: [:workers] do 
    update_crontab 
    end 

    after 'deploy:symlink', 'whenever:update_crontab' 
    %w[start stop restart].each do |command| 
    after "deploy:#{command}", "whenever:#{command}" 
    end 
end 

什麼我可能做錯了什麼想法?

寶石版本

  • Capistrano的(2.8.0)
  • 每當(0.8.2)
+0

這個問題似乎與隨時0.8.2,當我切換回到0.8.0它再次正常工作。 – Martinffx

回答

1

的方法中缺少Capistrano的引入2.9.0之後。

補丁:您可以在Capfile或deploy.rb文件的頂部添加此:

require 'capistrano/server_definition' 
require 'capistrano/role' 
class Capistrano::Configuration 
    def role_names_for_host(host) 
    roles.map {|role_name, role| role_name if role.include?(host) }.compact || [] 
    end 
end 

每當更新它,我會推薦的創業板市場的依賴:)

(來源:https://github.com/javan/whenever/issues/302#issuecomment-14962350