resque-mongo-scheduler 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +47 -0
- data/HISTORY.md +88 -0
- data/LICENSE +21 -0
- data/README.markdown +316 -0
- data/Rakefile +13 -0
- data/lib/resque/scheduler.rb +244 -0
- data/lib/resque_scheduler/search_delayed.rb +49 -0
- data/lib/resque_scheduler/server/views/delayed.erb +64 -0
- data/lib/resque_scheduler/server/views/delayed_timestamp.erb +26 -0
- data/lib/resque_scheduler/server/views/scheduler.erb +39 -0
- data/lib/resque_scheduler/server.rb +58 -0
- data/lib/resque_scheduler/tasks.rb +25 -0
- data/lib/resque_scheduler/version.rb +3 -0
- data/lib/resque_scheduler.rb +238 -0
- data/resque-mongo-scheduler.gemspec +29 -0
- data/tasks/resque_scheduler.rake +2 -0
- data/test/delayed_queue_test.rb +234 -0
- data/test/redis-test.conf +115 -0
- data/test/resque-web_test.rb +31 -0
- data/test/scheduler_args_test.rb +83 -0
- data/test/scheduler_test.rb +241 -0
- data/test/test_helper.rb +92 -0
- metadata +150 -0
@@ -0,0 +1,83 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
context "scheduling jobs with arguments" do
|
4
|
+
setup { Resque::Scheduler.clear_schedule! }
|
5
|
+
|
6
|
+
test "calls the worker without arguments when 'args' is missing from the config" do
|
7
|
+
Resque::Scheduler.enqueue_from_config(YAML.load(<<-YAML))
|
8
|
+
class: SomeIvarJob
|
9
|
+
YAML
|
10
|
+
SomeIvarJob.expects(:perform).once.with()
|
11
|
+
Resque.reserve('ivar').perform
|
12
|
+
end
|
13
|
+
|
14
|
+
test "calls the worker without arguments when 'args' is blank in the config" do
|
15
|
+
Resque::Scheduler.enqueue_from_config(YAML.load(<<-YAML))
|
16
|
+
class: SomeIvarJob
|
17
|
+
args:
|
18
|
+
YAML
|
19
|
+
SomeIvarJob.expects(:perform).once.with()
|
20
|
+
Resque.reserve('ivar').perform
|
21
|
+
end
|
22
|
+
|
23
|
+
test "calls the worker with a string when the config lists a string" do
|
24
|
+
Resque::Scheduler.enqueue_from_config(YAML.load(<<-YAML))
|
25
|
+
class: SomeIvarJob
|
26
|
+
args: string
|
27
|
+
YAML
|
28
|
+
SomeIvarJob.expects(:perform).once.with('string')
|
29
|
+
Resque.reserve('ivar').perform
|
30
|
+
end
|
31
|
+
|
32
|
+
test "calls the worker with a Fixnum when the config lists an integer" do
|
33
|
+
Resque::Scheduler.enqueue_from_config(YAML.load(<<-YAML))
|
34
|
+
class: SomeIvarJob
|
35
|
+
args: 1
|
36
|
+
YAML
|
37
|
+
SomeIvarJob.expects(:perform).once.with(1)
|
38
|
+
Resque.reserve('ivar').perform
|
39
|
+
end
|
40
|
+
|
41
|
+
test "calls the worker with multiple arguments when the config lists an array" do
|
42
|
+
Resque::Scheduler.enqueue_from_config(YAML.load(<<-YAML))
|
43
|
+
class: SomeIvarJob
|
44
|
+
args:
|
45
|
+
- 1
|
46
|
+
- 2
|
47
|
+
YAML
|
48
|
+
SomeIvarJob.expects(:perform).once.with(1, 2)
|
49
|
+
Resque.reserve('ivar').perform
|
50
|
+
end
|
51
|
+
|
52
|
+
test "calls the worker with an array when the config lists a nested array" do
|
53
|
+
Resque::Scheduler.enqueue_from_config(YAML.load(<<-YAML))
|
54
|
+
class: SomeIvarJob
|
55
|
+
args:
|
56
|
+
- - 1
|
57
|
+
- 2
|
58
|
+
YAML
|
59
|
+
SomeIvarJob.expects(:perform).once.with([1, 2])
|
60
|
+
Resque.reserve('ivar').perform
|
61
|
+
end
|
62
|
+
|
63
|
+
test "calls the worker with a hash when the config lists a hash" do
|
64
|
+
Resque::Scheduler.enqueue_from_config(YAML.load(<<-YAML))
|
65
|
+
class: SomeIvarJob
|
66
|
+
args:
|
67
|
+
key: value
|
68
|
+
YAML
|
69
|
+
SomeIvarJob.expects(:perform).once.with('key' => 'value')
|
70
|
+
Resque.reserve('ivar').perform
|
71
|
+
end
|
72
|
+
|
73
|
+
test "calls the worker with a nested hash when the config lists a nested hash" do
|
74
|
+
Resque::Scheduler.enqueue_from_config(YAML.load(<<-YAML))
|
75
|
+
class: SomeIvarJob
|
76
|
+
args:
|
77
|
+
first_key:
|
78
|
+
second_key: value
|
79
|
+
YAML
|
80
|
+
SomeIvarJob.expects(:perform).once.with('first_key' => {'second_key' => 'value'})
|
81
|
+
Resque.reserve('ivar').perform
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,241 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
class Resque::SchedulerTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
class FakeJob
|
6
|
+
def self.scheduled(queue, klass, *args); end
|
7
|
+
end
|
8
|
+
|
9
|
+
def setup
|
10
|
+
Resque::Scheduler.dynamic = false
|
11
|
+
Resque.flushall
|
12
|
+
Resque::Scheduler.mute = true
|
13
|
+
Resque::Scheduler.clear_schedule!
|
14
|
+
Resque::Scheduler.send(:class_variable_set, :@@scheduled_jobs, {})
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_enqueue_from_config_puts_stuff_in_the_resque_queue_without_class_loaded
|
18
|
+
Resque::Job.stubs(:create).once.returns(true).with('joes_queue', 'BigJoesJob', '/tmp')
|
19
|
+
Resque::Scheduler.enqueue_from_config('cron' => "* * * * *", 'class' => 'BigJoesJob', 'args' => "/tmp", 'queue' => 'joes_queue')
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_enqueue_from_config_with_every_syntax
|
23
|
+
Resque::Job.stubs(:create).once.returns(true).with('james_queue', 'JamesJob', '/tmp')
|
24
|
+
Resque::Scheduler.enqueue_from_config('every' => '1m', 'class' => 'JamesJob', 'args' => '/tmp', 'queue' => 'james_queue')
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_enqueue_from_config_puts_stuff_in_the_resque_queue
|
28
|
+
Resque::Job.stubs(:create).once.returns(true).with(:ivar, 'SomeIvarJob', '/tmp')
|
29
|
+
Resque::Scheduler.enqueue_from_config('cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp")
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_enqueue_from_config_with_custom_class_job_in_the_resque_queue
|
33
|
+
FakeJob.stubs(:scheduled).once.returns(true).with(:ivar, 'SomeIvarJob', '/tmp')
|
34
|
+
Resque::Scheduler.enqueue_from_config('cron' => "* * * * *", 'class' => 'SomeIvarJob', 'custom_job_class' => 'Resque::SchedulerTest::FakeJob', 'args' => "/tmp")
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_enqueue_from_config_puts_stuff_in_the_resque_queue_when_env_match
|
38
|
+
# The job should be loaded : its rails_env config matches the RAILS_ENV variable:
|
39
|
+
ENV['RAILS_ENV'] = 'production'
|
40
|
+
assert_equal(0, Resque::Scheduler.rufus_scheduler.all_jobs.size)
|
41
|
+
|
42
|
+
Resque.schedule = {:some_ivar_job => {'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp", 'rails_env' => 'production'}}
|
43
|
+
Resque::Scheduler.load_schedule!
|
44
|
+
assert_equal(1, Resque::Scheduler.rufus_scheduler.all_jobs.size)
|
45
|
+
|
46
|
+
# we allow multiple rails_env definition, it should work also:
|
47
|
+
Resque.schedule = {:some_ivar_job => {'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp", 'rails_env' => 'staging, production'}}
|
48
|
+
Resque::Scheduler.load_schedule!
|
49
|
+
assert_equal(2, Resque::Scheduler.rufus_scheduler.all_jobs.size)
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_enqueue_from_config_dont_puts_stuff_in_the_resque_queue_when_env_doesnt_match
|
53
|
+
# RAILS_ENV is not set:
|
54
|
+
assert_equal(0, Resque::Scheduler.rufus_scheduler.all_jobs.size)
|
55
|
+
Resque.schedule = {:some_ivar_job => {'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp", 'rails_env' => 'staging'}}
|
56
|
+
Resque::Scheduler.load_schedule!
|
57
|
+
assert_equal(0, Resque::Scheduler.rufus_scheduler.all_jobs.size)
|
58
|
+
|
59
|
+
# SET RAILS_ENV to a common value:
|
60
|
+
ENV['RAILS_ENV'] = 'production'
|
61
|
+
Resque.schedule = {:some_ivar_job => {'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp", 'rails_env' => 'staging'}}
|
62
|
+
Resque::Scheduler.load_schedule!
|
63
|
+
assert_equal(0, Resque::Scheduler.rufus_scheduler.all_jobs.size)
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_enqueue_from_config_when_rails_env_arg_is_not_set
|
67
|
+
# The job should be loaded, since a missing rails_env means ALL envs.
|
68
|
+
ENV['RAILS_ENV'] = 'production'
|
69
|
+
assert_equal(0, Resque::Scheduler.rufus_scheduler.all_jobs.size)
|
70
|
+
Resque.schedule = {:some_ivar_job => {'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp"}}
|
71
|
+
Resque::Scheduler.load_schedule!
|
72
|
+
assert_equal(1, Resque::Scheduler.rufus_scheduler.all_jobs.size)
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_config_makes_it_into_the_rufus_scheduler
|
76
|
+
assert_equal(0, Resque::Scheduler.rufus_scheduler.all_jobs.size)
|
77
|
+
|
78
|
+
Resque.schedule = {:some_ivar_job => {'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp"}}
|
79
|
+
Resque::Scheduler.load_schedule!
|
80
|
+
|
81
|
+
assert_equal(1, Resque::Scheduler.rufus_scheduler.all_jobs.size)
|
82
|
+
assert Resque::Scheduler.scheduled_jobs.include?(:some_ivar_job)
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_can_reload_schedule
|
86
|
+
Resque::Scheduler.dynamic = true
|
87
|
+
Resque.schedule = {"some_ivar_job" => {'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp"}}
|
88
|
+
|
89
|
+
Resque::Scheduler.load_schedule!
|
90
|
+
|
91
|
+
assert_equal(1, Resque::Scheduler.rufus_scheduler.all_jobs.size)
|
92
|
+
assert Resque::Scheduler.scheduled_jobs.include?("some_ivar_job")
|
93
|
+
|
94
|
+
Resque.schedules.remove
|
95
|
+
Resque.schedules.insert('_id' => "some_ivar_job2", 'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp/2")
|
96
|
+
|
97
|
+
Resque::Scheduler.reload_schedule!
|
98
|
+
|
99
|
+
assert_equal(1, Resque::Scheduler.rufus_scheduler.all_jobs.size)
|
100
|
+
|
101
|
+
assert_equal '/tmp/2', Resque.schedule["some_ivar_job2"]["args"]
|
102
|
+
assert Resque::Scheduler.scheduled_jobs.include?("some_ivar_job2")
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_load_schedule_job
|
106
|
+
Resque::Scheduler.load_schedule_job("some_ivar_job", {'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp"})
|
107
|
+
|
108
|
+
assert_equal(1, Resque::Scheduler.rufus_scheduler.all_jobs.size)
|
109
|
+
assert_equal(1, Resque::Scheduler.scheduled_jobs.size)
|
110
|
+
assert Resque::Scheduler.scheduled_jobs.keys.include?("some_ivar_job")
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_load_schedule_job_with_no_cron
|
114
|
+
Resque::Scheduler.load_schedule_job("some_ivar_job", {'class' => 'SomeIvarJob', 'args' => "/tmp"})
|
115
|
+
|
116
|
+
assert_equal(0, Resque::Scheduler.rufus_scheduler.all_jobs.size)
|
117
|
+
assert_equal(0, Resque::Scheduler.scheduled_jobs.size)
|
118
|
+
assert !Resque::Scheduler.scheduled_jobs.keys.include?("some_ivar_job")
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_load_schedule_job_with_blank_cron
|
122
|
+
Resque::Scheduler.load_schedule_job("some_ivar_job", {'cron' => '', 'class' => 'SomeIvarJob', 'args' => "/tmp"})
|
123
|
+
|
124
|
+
assert_equal(0, Resque::Scheduler.rufus_scheduler.all_jobs.size)
|
125
|
+
assert_equal(0, Resque::Scheduler.scheduled_jobs.size)
|
126
|
+
assert !Resque::Scheduler.scheduled_jobs.keys.include?("some_ivar_job")
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_update_schedule
|
130
|
+
Resque::Scheduler.dynamic = true
|
131
|
+
Resque.schedule = {
|
132
|
+
"some_ivar_job" => {'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp"},
|
133
|
+
"another_ivar_job" => {'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp/5"},
|
134
|
+
"stay_put_job" => {'cron' => "* * * * *", 'class' => 'SomeJob', 'args' => "/tmp"}
|
135
|
+
}
|
136
|
+
|
137
|
+
Resque::Scheduler.load_schedule!
|
138
|
+
assert_equal 0, Resque.schedules_changed.count
|
139
|
+
|
140
|
+
Resque.set_schedule("some_ivar_job",
|
141
|
+
{'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp/2"}
|
142
|
+
)
|
143
|
+
Resque.set_schedule("new_ivar_job",
|
144
|
+
{'cron' => "* * * * *", 'class' => 'SomeJob', 'args' => "/tmp/3"}
|
145
|
+
)
|
146
|
+
Resque.set_schedule("stay_put_job",
|
147
|
+
{'cron' => "* * * * *", 'class' => 'SomeJob', 'args' => "/tmp"}
|
148
|
+
)
|
149
|
+
Resque.remove_schedule("another_ivar_job")
|
150
|
+
|
151
|
+
Resque::Scheduler.update_schedule
|
152
|
+
|
153
|
+
assert_equal(3, Resque::Scheduler.rufus_scheduler.all_jobs.size)
|
154
|
+
assert_equal(3, Resque::Scheduler.scheduled_jobs.size)
|
155
|
+
%w(some_ivar_job new_ivar_job stay_put_job).each do |job_name|
|
156
|
+
assert Resque::Scheduler.scheduled_jobs.keys.include?(job_name)
|
157
|
+
assert Resque.schedule.keys.include?(job_name)
|
158
|
+
end
|
159
|
+
assert !Resque::Scheduler.scheduled_jobs.keys.include?("another_ivar_job")
|
160
|
+
assert !Resque.schedule.keys.include?("another_ivar_job")
|
161
|
+
assert_equal 0, Resque.schedules_changed.count
|
162
|
+
end
|
163
|
+
|
164
|
+
def test_update_schedule_with_mocks
|
165
|
+
Resque::Scheduler.dynamic = true
|
166
|
+
Resque.schedule = {
|
167
|
+
"some_ivar_job" => {'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp"},
|
168
|
+
"another_ivar_job" => {'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp/5"},
|
169
|
+
"stay_put_job" => {'cron' => "* * * * *", 'class' => 'SomeJob', 'args' => "/tmp"}
|
170
|
+
}
|
171
|
+
|
172
|
+
Resque::Scheduler.load_schedule!
|
173
|
+
|
174
|
+
Resque::Scheduler.rufus_scheduler.expects(:unschedule).with(Resque::Scheduler.scheduled_jobs["some_ivar_job"].job_id)
|
175
|
+
Resque::Scheduler.rufus_scheduler.expects(:unschedule).with(Resque::Scheduler.scheduled_jobs["another_ivar_job"].job_id)
|
176
|
+
|
177
|
+
Resque.set_schedule("some_ivar_job",
|
178
|
+
{'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp/2"}
|
179
|
+
)
|
180
|
+
Resque.set_schedule("new_ivar_job",
|
181
|
+
{'cron' => "* * * * *", 'class' => 'SomeJob', 'args' => "/tmp/3"}
|
182
|
+
)
|
183
|
+
Resque.set_schedule("stay_put_job",
|
184
|
+
{'cron' => "* * * * *", 'class' => 'SomeJob', 'args' => "/tmp"}
|
185
|
+
)
|
186
|
+
Resque.remove_schedule("another_ivar_job")
|
187
|
+
|
188
|
+
Resque::Scheduler.update_schedule
|
189
|
+
|
190
|
+
assert_equal(3, Resque::Scheduler.scheduled_jobs.size)
|
191
|
+
%w(some_ivar_job new_ivar_job stay_put_job).each do |job_name|
|
192
|
+
assert Resque::Scheduler.scheduled_jobs.keys.include?(job_name)
|
193
|
+
assert Resque.schedule.keys.include?(job_name)
|
194
|
+
end
|
195
|
+
assert !Resque::Scheduler.scheduled_jobs.keys.include?("another_ivar_job")
|
196
|
+
assert !Resque.schedule.keys.include?("another_ivar_job")
|
197
|
+
assert_equal 0, Resque.schedules_changed.count
|
198
|
+
end
|
199
|
+
|
200
|
+
def test_set_schedules
|
201
|
+
Resque::Scheduler.dynamic = true
|
202
|
+
Resque.schedule = {"some_ivar_job" => {
|
203
|
+
'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp/75"
|
204
|
+
}}
|
205
|
+
assert_equal({'_id' => "some_ivar_job", 'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp/75"},
|
206
|
+
Resque.schedules.find_one('_id' => "some_ivar_job"))
|
207
|
+
end
|
208
|
+
|
209
|
+
def test_set_schedule
|
210
|
+
assert_equal 0, Resque.schedules_changed.find('_id' => "some_ivar_job").count
|
211
|
+
Resque.set_schedule("some_ivar_job", {
|
212
|
+
'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp/22"
|
213
|
+
})
|
214
|
+
assert_equal({'_id' => "some_ivar_job", 'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp/22"},
|
215
|
+
Resque.schedules.find_one('_id' => "some_ivar_job"))
|
216
|
+
assert_equal 1, Resque.schedules_changed.find('_id' => "some_ivar_job").count
|
217
|
+
end
|
218
|
+
|
219
|
+
def test_get_schedule
|
220
|
+
schedule = {'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp/33"}
|
221
|
+
Resque.schedules.insert(schedule.merge('_id' => "some_ivar_job2"))
|
222
|
+
assert_equal(schedule,
|
223
|
+
Resque.get_schedule("some_ivar_job2"))
|
224
|
+
end
|
225
|
+
|
226
|
+
def test_remove_schedule
|
227
|
+
assert_equal 0, Resque.schedules_changed.find('_id' => "some_ivar_job3").count
|
228
|
+
Resque.schedules.insert('_id' => "some_ivar_job3", 'cron' => "* * * * *", 'class' => 'SomeIvarJob', 'args' => "/tmp/44")
|
229
|
+
Resque.remove_schedule("some_ivar_job3")
|
230
|
+
assert_equal nil, Resque.schedules.find_one('_id' => "some_ivar_job3")
|
231
|
+
assert_equal 1, Resque.schedules_changed.find('_id' => "some_ivar_job3").count
|
232
|
+
end
|
233
|
+
|
234
|
+
def test_adheres_to_lint
|
235
|
+
assert_nothing_raised do
|
236
|
+
Resque::Plugin.lint(Resque::Scheduler)
|
237
|
+
Resque::Plugin.lint(ResqueScheduler)
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
|
2
|
+
# Pretty much copied this file from the resque-mongo test_helper since we want
|
3
|
+
# to do all the same stuff
|
4
|
+
|
5
|
+
dir = File.dirname(File.expand_path(__FILE__))
|
6
|
+
|
7
|
+
require 'rubygems'
|
8
|
+
require 'test/unit'
|
9
|
+
require 'mocha'
|
10
|
+
gem 'resque-mongo'
|
11
|
+
require 'resque'
|
12
|
+
require File.join(dir, '../lib/resque_scheduler')
|
13
|
+
$LOAD_PATH.unshift File.dirname(File.expand_path(__FILE__)) + '/../lib'
|
14
|
+
|
15
|
+
|
16
|
+
#
|
17
|
+
# make sure we can run redis
|
18
|
+
#
|
19
|
+
|
20
|
+
# if !system("which redis-server")
|
21
|
+
# puts '', "** can't find `redis-server` in your path"
|
22
|
+
# puts "** try running `sudo rake install`"
|
23
|
+
# abort ''
|
24
|
+
# end
|
25
|
+
|
26
|
+
|
27
|
+
#
|
28
|
+
# start our own redis when the tests start,
|
29
|
+
# kill it when they end
|
30
|
+
#
|
31
|
+
|
32
|
+
# at_exit do
|
33
|
+
# next if $!
|
34
|
+
#
|
35
|
+
# if defined?(MiniTest)
|
36
|
+
# exit_code = MiniTest::Unit.new.run(ARGV)
|
37
|
+
# else
|
38
|
+
# exit_code = Test::Unit::AutoRunner.run
|
39
|
+
# end
|
40
|
+
#
|
41
|
+
# pid = `ps -e -o pid,command | grep [r]edis-test`.split(" ")[0]
|
42
|
+
# puts "Killing test redis server..."
|
43
|
+
# `rm -f #{dir}/dump.rdb`
|
44
|
+
# Process.kill("KILL", pid.to_i)
|
45
|
+
# exit exit_code
|
46
|
+
# end
|
47
|
+
|
48
|
+
Resque.mongo = 'localhost:27017'
|
49
|
+
|
50
|
+
module Resque
|
51
|
+
# Drop all collections in the 'monque' database.
|
52
|
+
# Note: do not drop the database directly, as mongod allocates disk space
|
53
|
+
# each time it's re-created.
|
54
|
+
def flushall
|
55
|
+
for name in @db.collection_names
|
56
|
+
begin
|
57
|
+
@db.drop_collection(name)
|
58
|
+
rescue Mongo::OperationFailure
|
59
|
+
# "can't drop system ns"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
##
|
66
|
+
# test/spec/mini 3
|
67
|
+
# http://gist.github.com/25455
|
68
|
+
# chris@ozmm.org
|
69
|
+
#
|
70
|
+
def context(*args, &block)
|
71
|
+
return super unless (name = args.first) && block
|
72
|
+
require 'test/unit'
|
73
|
+
klass = Class.new(defined?(ActiveSupport::TestCase) ? ActiveSupport::TestCase : Test::Unit::TestCase) do
|
74
|
+
def self.test(name, &block)
|
75
|
+
define_method("test_#{name.gsub(/\W/,'_')}", &block) if block
|
76
|
+
end
|
77
|
+
def self.xtest(*args) end
|
78
|
+
def self.setup(&block) define_method(:setup, &block) end
|
79
|
+
def self.teardown(&block) define_method(:teardown, &block) end
|
80
|
+
end
|
81
|
+
(class << klass; self end).send(:define_method, :name) { name.gsub(/\W/,'_') }
|
82
|
+
klass.class_eval &block
|
83
|
+
end
|
84
|
+
|
85
|
+
class SomeJob
|
86
|
+
def self.perform(repo_id, path)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
class SomeIvarJob < SomeJob
|
91
|
+
@queue = :ivar
|
92
|
+
end
|
metadata
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: resque-mongo-scheduler
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 2.0.2
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ben VandenBos
|
9
|
+
- "Nicolas Fouch\xC3\xA9"
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
|
14
|
+
date: 2011-03-24 00:00:00 +01:00
|
15
|
+
default_executable:
|
16
|
+
dependencies:
|
17
|
+
- !ruby/object:Gem::Dependency
|
18
|
+
name: bundler
|
19
|
+
prerelease: false
|
20
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
21
|
+
none: false
|
22
|
+
requirements:
|
23
|
+
- - ">="
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: 1.0.0
|
26
|
+
type: :development
|
27
|
+
version_requirements: *id001
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: mongo
|
30
|
+
prerelease: false
|
31
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
32
|
+
none: false
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: "1.1"
|
37
|
+
type: :runtime
|
38
|
+
version_requirements: *id002
|
39
|
+
- !ruby/object:Gem::Dependency
|
40
|
+
name: resque-mongo
|
41
|
+
prerelease: false
|
42
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.11.0
|
48
|
+
type: :runtime
|
49
|
+
version_requirements: *id003
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: rufus-scheduler
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: "0"
|
59
|
+
type: :runtime
|
60
|
+
version_requirements: *id004
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: mocha
|
63
|
+
prerelease: false
|
64
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: "0"
|
70
|
+
type: :development
|
71
|
+
version_requirements: *id005
|
72
|
+
- !ruby/object:Gem::Dependency
|
73
|
+
name: rack-test
|
74
|
+
prerelease: false
|
75
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: "0"
|
81
|
+
type: :development
|
82
|
+
version_requirements: *id006
|
83
|
+
description: |-
|
84
|
+
Light weight job scheduling on top of Resque Mongo.
|
85
|
+
Adds methods enqueue_at/enqueue_in to schedule jobs in the future.
|
86
|
+
Also supports queueing jobs on a fixed, cron-like schedule.
|
87
|
+
email:
|
88
|
+
- bvandenbos@gmail.com
|
89
|
+
- nicolas@silentale.com
|
90
|
+
executables: []
|
91
|
+
|
92
|
+
extensions: []
|
93
|
+
|
94
|
+
extra_rdoc_files: []
|
95
|
+
|
96
|
+
files:
|
97
|
+
- .gitignore
|
98
|
+
- Gemfile
|
99
|
+
- Gemfile.lock
|
100
|
+
- HISTORY.md
|
101
|
+
- LICENSE
|
102
|
+
- README.markdown
|
103
|
+
- Rakefile
|
104
|
+
- lib/resque/scheduler.rb
|
105
|
+
- lib/resque_scheduler.rb
|
106
|
+
- lib/resque_scheduler/search_delayed.rb
|
107
|
+
- lib/resque_scheduler/server.rb
|
108
|
+
- lib/resque_scheduler/server/views/delayed.erb
|
109
|
+
- lib/resque_scheduler/server/views/delayed_timestamp.erb
|
110
|
+
- lib/resque_scheduler/server/views/scheduler.erb
|
111
|
+
- lib/resque_scheduler/tasks.rb
|
112
|
+
- lib/resque_scheduler/version.rb
|
113
|
+
- resque-mongo-scheduler.gemspec
|
114
|
+
- tasks/resque_scheduler.rake
|
115
|
+
- test/delayed_queue_test.rb
|
116
|
+
- test/redis-test.conf
|
117
|
+
- test/resque-web_test.rb
|
118
|
+
- test/scheduler_args_test.rb
|
119
|
+
- test/scheduler_test.rb
|
120
|
+
- test/test_helper.rb
|
121
|
+
has_rdoc: true
|
122
|
+
homepage: http://github.com/nfo/resque-mongo-scheduler
|
123
|
+
licenses: []
|
124
|
+
|
125
|
+
post_install_message:
|
126
|
+
rdoc_options: []
|
127
|
+
|
128
|
+
require_paths:
|
129
|
+
- lib
|
130
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
131
|
+
none: false
|
132
|
+
requirements:
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: "0"
|
136
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: 1.3.6
|
142
|
+
requirements: []
|
143
|
+
|
144
|
+
rubyforge_project:
|
145
|
+
rubygems_version: 1.6.1
|
146
|
+
signing_key:
|
147
|
+
specification_version: 3
|
148
|
+
summary: Light weight job scheduling on top of Resque Mongo
|
149
|
+
test_files: []
|
150
|
+
|