gpt4 book ai didi

ruby-on-rails - 每当 gem 指定在哪个服务器上运行每个作业时

转载 作者:行者123 更新时间:2023-12-01 23:59:58 24 4
gpt4 key购买 nike

根据何时文档可以指定一组everyone_roles( https://github.com/javan/whenever#capistrano-roles )。现在我想在 schedule.rb 中定义一组 cronjobs 并根据它们的角色划分它们,如下所示:

set :output, "log/cron.log"

every :day, at: '11:00', roles: :whenever_alt do
runner 'MySuperScriptClass1.start'
end

every :day, at: '12:30', roles: :whenever_main do
runner 'MySuperScriptClass2.start'
end

和部署文件
set :whenever_roles, ["whenever_main", "whenever_alt"]

在生产.rb
role :whenever_main,  %w{ip_address_1}
role :whenever_alt, %w{ip_address_2}

问题是,当我使用该配置部署 capistrano 时,我得到
cap aborted!
undefined method `to_sym' for [:whenever_main, :whenever_alt]:Array
/Users/.../gems/capistrano-
3.0.1/lib/capistrano/configuration/servers/role_filter.rb:25:in `each'
/Users/.../gems/capistrano-3.0.1/lib/capistrano/configuration/servers/role_filter.rb:25:in
`flat_map'
/Users/.../gems/capistrano-3.0.1/lib/capistrano/configuration/servers/role_filter.rb:25:in
`required'
/Users/.../gems/capistrano-3.0.1/lib/capistrano/configuration/servers/role_filter.rb:15:in
`roles'
/Users/.../gems/capistrano-3.0.1/lib/capistrano/configuration/servers/role_filter.rb:11:in
`for'
/Users/.../gems/capistrano-3.0.1/lib/capistrano/configuration/servers.rb:45:in
`fetch_roles'
/Users/.../gems/capistrano-3.0.1/lib/capistrano/configuration/servers.rb:18:in
`roles_for'
/Users/.../gems/capistrano-3.0.1/lib/capistrano/configuration.rb:45:in `roles_for'

/Users/.../gems/capistrano-3.0.1/lib/capistrano/dsl/env.rb:43:in `roles'
/Users/.../gems/whenever-0.9.0/lib/whenever/tasks/whenever.rake:4:in `block (2 levels) in <top (required)>'

如何在每台服务器上使用任何时候将 cronjobs 分开?

非常感谢

最佳答案

1) 在您的 schedule.rb , 将角色组成数组

every :day, at: '11:00', roles: [:whenever_alt] do # NOTE that ":whenever_alt" is now "[:whenever_alt]"
runner 'MySuperScriptClass1.start'
end

every :day, at: '12:30', roles: [:whenever_main] do
runner 'MySuperScriptClass2.start'
end

2)确保您的版本至少为 0.9.1

关于ruby-on-rails - 每当 gem 指定在哪个服务器上运行每个作业时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22001009/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com