我正在使用/ capistrano在使用capistrano进行部署时更新我的cron_tab,直到最近我的部署在更新cron_tab时才开始失败。
.rvm/gems/ruby-1.9.3-p362-turbo@psg-web/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
关于我可能做错的任何想法?
宝石版
答案 0 :(得分:1)
在2.9.0之后的capistrano中引入了缺失的方法。
修补程序:您可以将其添加到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
我建议每当更新它的gem依赖项时:)
(来源:https://github.com/javan/whenever/issues/302#issuecomment-14962350)