如何使用 sidekiq-scheduler 每 30 秒进行一次调度
how to schedule for every 30 seconds with sidekiq-scheduler
我正在处理 ROR 申请。
我有一个功能需求,我必须调用一个方法
每 30 秒使用 sidekiq
我正在使用这些 gems
# sidekiq
gem 'sidekiq', '~> 3.3.0'
# sidekiq scheduler
gem 'sidekiq-scheduler', '~> 2.0'
这是我的 scheduler.yml 文件代码。
perform:
every: ["30s"]
class: Aggregator
queue: aggregation
description: "This job will create Aggregate data."
这是我的聚合器 class,它位于 Workers 文件夹中。
class Aggregator
include Sidekiq::Worker
sidekiq_options :backtrace => 5, :retry => false
def perform
end_time = time - (time.sec%30).seconds
puts "ROUNDING TO 30 SEC"
puts end_time
Session.create_aggregate_data(end_time)
end
end
当我检查 sidekiq 日志时,它没有触发执行方法。但是聚合器 class 正在调用
这是日志..
2016-07-27T10:19:59.436Z 15117 TID-1qjnlu INFO: queueing Aggregator (perform)
2016-07-27T10:20:29.641Z 15117 TID-1qjnlu INFO: queueing Aggregator (perform)
2016-07-27T10:20:59.836Z 15117 TID-1qjnlu INFO: queueing Aggregator (perform)
2016-07-27T10:21:30.009Z 15117 TID-1qjnlu INFO: queueing Aggregator (perform)
2016-07-27T10:22:00.204Z 15117 TID-1qjnlu INFO: queueing Aggregator (perform)
2016-07-27T10:22:30.507Z 15117 TID-1qjnlu INFO: queueing Aggregator (perform)
2016-07-27T10:23:00.509Z 15117 TID-1qjnlu INFO: queueing Aggregator (perform)
2016-07-27T10:23:30.760Z 15117 TID-1qjnlu INFO: queueing Aggregator (perform)
2016-07-27T10:24:01.068Z 15117 TID-1qjnlu INFO: queueing Aggregator (perform)
如果您没有配置非默认队列,请尝试将队列设置为默认
queue: default
我正在处理 ROR 申请。 我有一个功能需求,我必须调用一个方法 每 30 秒使用 sidekiq
我正在使用这些 gems
# sidekiq
gem 'sidekiq', '~> 3.3.0'
# sidekiq scheduler
gem 'sidekiq-scheduler', '~> 2.0'
这是我的 scheduler.yml 文件代码。
perform:
every: ["30s"]
class: Aggregator
queue: aggregation
description: "This job will create Aggregate data."
这是我的聚合器 class,它位于 Workers 文件夹中。
class Aggregator
include Sidekiq::Worker
sidekiq_options :backtrace => 5, :retry => false
def perform
end_time = time - (time.sec%30).seconds
puts "ROUNDING TO 30 SEC"
puts end_time
Session.create_aggregate_data(end_time)
end
end
当我检查 sidekiq 日志时,它没有触发执行方法。但是聚合器 class 正在调用
这是日志..
2016-07-27T10:19:59.436Z 15117 TID-1qjnlu INFO: queueing Aggregator (perform)
2016-07-27T10:20:29.641Z 15117 TID-1qjnlu INFO: queueing Aggregator (perform)
2016-07-27T10:20:59.836Z 15117 TID-1qjnlu INFO: queueing Aggregator (perform)
2016-07-27T10:21:30.009Z 15117 TID-1qjnlu INFO: queueing Aggregator (perform)
2016-07-27T10:22:00.204Z 15117 TID-1qjnlu INFO: queueing Aggregator (perform)
2016-07-27T10:22:30.507Z 15117 TID-1qjnlu INFO: queueing Aggregator (perform)
2016-07-27T10:23:00.509Z 15117 TID-1qjnlu INFO: queueing Aggregator (perform)
2016-07-27T10:23:30.760Z 15117 TID-1qjnlu INFO: queueing Aggregator (perform)
2016-07-27T10:24:01.068Z 15117 TID-1qjnlu INFO: queueing Aggregator (perform)
如果您没有配置非默认队列,请尝试将队列设置为默认
queue: default