Last active
August 29, 2015 13:57
-
-
Save bugant/9428282 to your computer and use it in GitHub Desktop.
Trying to reproduce resque-scheduler #369 issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'resque-scheduler' | |
class Foo | |
def self.queue | |
:foo | |
end | |
def message | |
'hello from foo' | |
end | |
def self.perform | |
File.open('/tmp/foo', 'a+') do |f| | |
f.puts "#{Time.now}: #{message}" | |
end | |
end | |
end | |
class Bar < Foo | |
def message | |
'hello from bar' | |
end | |
end | |
name = 'foo' | |
Resque.remove_schedule(name) | |
config = {} | |
config[:description] = 'Just foo' | |
config[:class] = 'Foo' | |
config[:cron] = "* * * * *" | |
config[:persist] = true | |
config[:queue] = :foo | |
Resque.set_schedule(name, config) | |
Resque.remove_schedule('bar') | |
config = {} | |
config[:description] = 'Just bar' | |
config[:class] = 'Bar' | |
config[:cron] = "* * * * *" | |
config[:persist] = true | |
config[:queue] = :foo | |
Resque.set_schedule('bar', config) | |
sleep(120) | |
t = Time.now.min | |
if t > 53 | |
t = 0 | |
end | |
Resque.remove_schedule(name) | |
config = {} | |
config[:description] = 'Just foo' | |
config[:class] = 'Foo' | |
config[:cron] = "#{t + 2},#{t + 4},#{t + 6} * * * *" | |
config[:persist] = true | |
config[:queue] = :foo | |
Resque.set_schedule(name, config) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment