当我运行我的发条文件时,事件被注册了两次。难道我做错了什么?
我在本地运行 CLI 进行测试:
clockwork app/lib/clockwork/clock.rb
时钟.rb:
require 'clockwork'
require 'active_support/time'
require './config/boot'
require './config/environment'
module Clockwork
handler do |job, time|
puts "Running #{job} at #{time}"
puts
end
every(1.hour, 'test') do
puts 'RUNNING TEST'
end
end
输出:
I, INFO -- : Starting clock for 2 events: [ test test ]
I, INFO -- : Triggering 'test'
BLOCK RUNNING TEST
I, INFO -- : Triggering 'test'
BLOCK RUNNING TEST