我的类如下:
class GetDataWorker
# To change this template use File | Settings | File Templates.
include Sidekiq::Worker
include Sidetiq::Schedulable
recurrence { minutely(15) }
def perform
# do stuff ...
puts "#{Time.now}"
CicsasNum.new.get_cicsas_num
InformixDbsSpace.new.get_db_space
end
end
执行命令后提示:
bundle exec sidekiq
/Users/liucc/.rvm/gems/ruby-1.9.2-p320/gems/actionpack-3.2.12/lib/action_dispatch/http/mime_type.rb:102: warning: already initialized constant PDF
undefined method `recurrence' for GetDataWorker:Class
/Users/liucc/omm/app/workers/get_data_worker.rb:6:in `<class:GetDataWorker>'
recurrence 这个方法怎么找不到啊?
#4 楼 @helloword 谢谢! 但是这个又是怎么回事?
2013-11-25T11:02:56Z 10709 TID-owqr984b4 INFO: [Sidetiq] Sidetiq v0.4.3 - Copyright (c) 2012-2013, Tobias Svensson <[email protected]>
2013-11-25T11:02:56Z 10709 TID-owqr984b4 INFO: [Sidetiq] Sidetiq is covered by the 3-clause BSD license.
2013-11-25T11:02:56Z 10709 TID-owqr984b4 INFO: [Sidetiq] See LICENSE and http://opensource.org/licenses/BSD-3-Clause for licensing details.
2013-11-25T11:02:56Z 10709 TID-owqr984b4 INFO: [Sidetiq] Sidetiq::Supervisor start
2013-11-25T11:02:56Z 10709 TID-owqrotyb8 INFO: [Sidetiq] Sidetiq::Actor::Clock id: 70272553391540 initialize
2013-11-25T11:02:56Z 10709 TID-owqrvjc8g INFO: [Sidetiq] Sidetiq::Actor::Handler id: 70272572944420 initialize
2013-11-25T11:02:56Z 10709 TID-owqrvgpfo INFO: [Sidetiq] Sidetiq::Actor::Handler id: 70272572807740 initialize
2013-11-25T11:02:56Z 10709 TID-owqrvgdbk INFO: [Sidetiq] Sidetiq::Actor::Handler id: 70272572794800 initialize
2013-11-25T11:02:56Z 10709 TID-owqrvfxi4 INFO: [Sidetiq] Sidetiq::Actor::Handler id: 70272572771580 initialize
2013-11-25T11:02:56Z 10709 TID-owqrotyb8 WARN: [Sidetiq] Can't link Sidetiq::Actor::Clock. Sidekiq::Manager not running. Retrying in 5 seconds ...
2013-11-25T11:02:56Z 10709 TID-owqrvjc8g WARN: [Sidetiq] Can't link Sidetiq::Actor::Handler. Sidekiq::Manager not running. Retrying in 5 seconds ...
2013-11-25T11:02:56Z 10709 TID-owqrvgpfo WARN: [Sidetiq] Can't link Sidetiq::Actor::Handler. Sidekiq::Manager not running. Retrying in 5 seconds ...
2013-11-25T11:02:56Z 10709 TID-owqrvgdbk WARN: [Sidetiq] Can't link Sidetiq::Actor::Handler. Sidekiq::Manager not running. Retrying in 5 seconds ...
2013-11-25T11:02:56Z 10709 TID-owqrvfxi4 WARN: [Sidetiq] Can't link Sidetiq::Actor::Handler. Sidekiq::Manager not running. Retrying in 5 seconds ...
/Users/liucc/.rvm/gems/ruby-1.9.2-p320/gems/actionpack-3.2.12/lib/action_dispatch/http/mime_type.rb:102: warning: already initialized constant PDF
2013-11-25T11:02:59Z 10709 TID-owqr984b4 INFO: Booting Sidekiq 2.15.2 using redis://localhost:6379/0 with options {}
2013-11-25T11:02:59Z 10709 TID-owqr984b4 INFO: Running in ruby 1.9.2p320 (2012-04-20 revision 35421) [x86_64-darwin12.2.0]
2013-11-25T11:02:59Z 10709 TID-owqr984b4 INFO: See LICENSE and the LGPL-3.0 for licensing details.
2013-11-25T11:02:59Z 10709 TID-owqr984b4 INFO: Starting processing, hit Ctrl-C to stop
2013-11-25T11:03:24Z 10709 TID-owqrz8xf0 WARN: Sidekiq died due to the following error, cannot recover, process exiting
2013-11-25T11:03:24Z 10709 TID-owqrz8xf0 WARN: linking timeout of 5 seconds exceeded
2013-11-25T11:03:24Z 10709 TID-owqrz8xf0 WARN: /Users/liucc/.rvm/gems/ruby-1.9.2-p320/gems/celluloid-0.15.2/lib/celluloid/actor.rb:217:in `block (2 levels) in linking_request'
/Users/liucc/.rvm/gems/ruby-1.9.2-p320/gems/celluloid-0.15.2/lib/celluloid/actor.rb:203:in `loop'
/Users/liucc/.rvm/gems/ruby-1.9.2-p320/gems/celluloid-0.15.2/lib/celluloid/actor.rb:203:in `block in linking_request'
/Users/liucc/.rvm/gems/ruby-1.9.2-p320/gems/celluloid-0.15.2/lib/celluloid/tasks.rb:109:in `exclusive'
/Users/liucc/.rvm/gems/ruby-1.9.2-p320/gems/celluloid-0.15.2/lib/celluloid.rb:431:in `exclusive'
/Users/liucc/.rvm/gems/ruby-1.9.2-p320/gems/celluloid-0.15.2/lib/celluloid/actor.rb:198:in `linking_request'
/Users/liucc/.rvm/gems/ruby-1.9.2-p320/gems/celluloid-0.15.2/lib/celluloid/actor.rb:90:in `monitor'
/Users/liucc/.rvm/gems/ruby-1.9.2-p320/gems/celluloid-0.15.2/lib/celluloid/actor.rb:101:in `link'
/Users/liucc/.rvm/gems/ruby-1.9.2-p320/gems/celluloid-0.15.2/lib/celluloid.rb:383:in `link'
/Users/liucc/.rvm/gems/ruby-1.9.2-p320/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in `public_send'
/Users/liucc/.rvm/gems/ruby-1.9.2-p320/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in `dispatch'
/Users/liucc/.rvm/gems/ruby-1.9.2-p320/gems/celluloid-0.15.2/lib/celluloid/calls.rb:67:in `dispatch'
/Users/liucc/.rvm/gems/ruby-1.9.2-p320/gems/celluloid-0.15.2/lib/celluloid/actor.rb:322:in `block in handle_message'
/Users/liucc/.rvm/gems/ruby-1.9.2-p320/gems/celluloid-0.15.2/lib/celluloid/actor.rb:416:in `block in task'
/Users/liucc/.rvm/gems/ruby-1.9.2-p320/gems/celluloid-0.15.2/lib/celluloid/tasks.rb:55:in `block in initialize'
/Users/liucc/.rvm/gems/ruby-1.9.2-p320/gems/celluloid-0.15.2/lib/celluloid/tasks/task_fiber.rb:13:in `block in create'
2013-11-25T11:03:25Z 10709 TID-owqrvjc8g INFO: [Sidetiq] Sidetiq::Actor::Handler id: 70272572944420 shutting down ...
#14 楼 @small_fish__ 我发现是 recurrence 写法的问题,我用 ice_cube 写法就会有问题。 只能这样写 recurrence { hourly.minute_of_hour(0, 15, 30, 45) } 不能这样写 recurrence { minutely(15) } 因为:Unfortunately, using ice_cube's interval methods is terribly slow on start-up (it tends to eat up 100% CPU for quite a while) and on every recurrence run. This is due to it calculating every possible occurrence since the schedule's start time. The way around is to avoid using them.