resque-scheduler 4.0.0 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of resque-scheduler might be problematic. Click here for more details.
- checksums.yaml +5 -13
- data/.rubocop.yml +2 -0
- data/.rubocop_todo.yml +32 -26
- data/.travis.yml +3 -8
- data/AUTHORS.md +3 -0
- data/README.md +14 -3
- data/lib/resque/scheduler.rb +12 -15
- data/lib/resque/scheduler/cli.rb +3 -1
- data/lib/resque/scheduler/configuration.rb +1 -1
- data/lib/resque/scheduler/delaying_extensions.rb +40 -11
- data/lib/resque/scheduler/env.rb +6 -18
- data/lib/resque/scheduler/server.rb +11 -5
- data/lib/resque/scheduler/server/views/delayed.erb +1 -2
- data/lib/resque/scheduler/server/views/search.erb +1 -2
- data/lib/resque/scheduler/signal_handling.rb +1 -1
- data/lib/resque/scheduler/util.rb +1 -3
- data/lib/resque/scheduler/version.rb +1 -1
- data/resque-scheduler.gemspec +5 -3
- data/test/cli_test.rb +5 -0
- data/test/delayed_queue_test.rb +277 -0
- data/test/scheduler_test.rb +18 -6
- data/test/test_helper.rb +7 -12
- data/test/util_test.rb +6 -0
- metadata +77 -49
- data/test/support/redis_instance.rb +0 -133
data/test/util_test.rb
CHANGED
@@ -8,4 +8,10 @@ context 'Util' do
|
|
8
8
|
test 'constantizing' do
|
9
9
|
assert util.constantize('Resque::Scheduler') == Resque::Scheduler
|
10
10
|
end
|
11
|
+
|
12
|
+
module ReSchedulIzer; end
|
13
|
+
|
14
|
+
test 'constantizing with a dash' do
|
15
|
+
assert util.constantize('re-schedul-izer') == ReSchedulIzer
|
16
|
+
end
|
11
17
|
end
|
metadata
CHANGED
@@ -1,214 +1,243 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resque-scheduler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben VandenBos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: json
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: kramdown
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: mocha
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
|
-
- -
|
73
|
+
- - ">="
|
60
74
|
- !ruby/object:Gem::Version
|
61
75
|
version: '0'
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
|
-
- -
|
80
|
+
- - ">="
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: pry
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
|
-
- -
|
87
|
+
- - ">="
|
74
88
|
- !ruby/object:Gem::Version
|
75
89
|
version: '0'
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
|
-
- -
|
94
|
+
- - ">="
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: rack-test
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
|
-
- -
|
101
|
+
- - ">="
|
88
102
|
- !ruby/object:Gem::Version
|
89
103
|
version: '0'
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
|
-
- -
|
108
|
+
- - ">="
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: rake
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
100
114
|
requirements:
|
101
|
-
- -
|
115
|
+
- - ">="
|
102
116
|
- !ruby/object:Gem::Version
|
103
117
|
version: '0'
|
104
118
|
type: :development
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
107
121
|
requirements:
|
108
|
-
- -
|
122
|
+
- - ">="
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: '0'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: simplecov
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
114
128
|
requirements:
|
115
|
-
- -
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: test-unit
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
116
144
|
- !ruby/object:Gem::Version
|
117
145
|
version: '0'
|
118
146
|
type: :development
|
119
147
|
prerelease: false
|
120
148
|
version_requirements: !ruby/object:Gem::Requirement
|
121
149
|
requirements:
|
122
|
-
- -
|
150
|
+
- - ">="
|
123
151
|
- !ruby/object:Gem::Version
|
124
152
|
version: '0'
|
125
153
|
- !ruby/object:Gem::Dependency
|
126
154
|
name: yard
|
127
155
|
requirement: !ruby/object:Gem::Requirement
|
128
156
|
requirements:
|
129
|
-
- -
|
157
|
+
- - ">="
|
130
158
|
- !ruby/object:Gem::Version
|
131
159
|
version: '0'
|
132
160
|
type: :development
|
133
161
|
prerelease: false
|
134
162
|
version_requirements: !ruby/object:Gem::Requirement
|
135
163
|
requirements:
|
136
|
-
- -
|
164
|
+
- - ">="
|
137
165
|
- !ruby/object:Gem::Version
|
138
166
|
version: '0'
|
139
167
|
- !ruby/object:Gem::Dependency
|
140
168
|
name: rubocop
|
141
169
|
requirement: !ruby/object:Gem::Requirement
|
142
170
|
requirements:
|
143
|
-
- - ~>
|
171
|
+
- - "~>"
|
144
172
|
- !ruby/object:Gem::Version
|
145
|
-
version: 0.
|
173
|
+
version: 0.35.1
|
146
174
|
type: :development
|
147
175
|
prerelease: false
|
148
176
|
version_requirements: !ruby/object:Gem::Requirement
|
149
177
|
requirements:
|
150
|
-
- - ~>
|
178
|
+
- - "~>"
|
151
179
|
- !ruby/object:Gem::Version
|
152
|
-
version: 0.
|
180
|
+
version: 0.35.1
|
153
181
|
- !ruby/object:Gem::Dependency
|
154
182
|
name: mono_logger
|
155
183
|
requirement: !ruby/object:Gem::Requirement
|
156
184
|
requirements:
|
157
|
-
- - ~>
|
185
|
+
- - "~>"
|
158
186
|
- !ruby/object:Gem::Version
|
159
187
|
version: '1.0'
|
160
188
|
type: :runtime
|
161
189
|
prerelease: false
|
162
190
|
version_requirements: !ruby/object:Gem::Requirement
|
163
191
|
requirements:
|
164
|
-
- - ~>
|
192
|
+
- - "~>"
|
165
193
|
- !ruby/object:Gem::Version
|
166
194
|
version: '1.0'
|
167
195
|
- !ruby/object:Gem::Dependency
|
168
196
|
name: redis
|
169
197
|
requirement: !ruby/object:Gem::Requirement
|
170
198
|
requirements:
|
171
|
-
- - ~>
|
199
|
+
- - "~>"
|
172
200
|
- !ruby/object:Gem::Version
|
173
201
|
version: '3.0'
|
174
202
|
type: :runtime
|
175
203
|
prerelease: false
|
176
204
|
version_requirements: !ruby/object:Gem::Requirement
|
177
205
|
requirements:
|
178
|
-
- - ~>
|
206
|
+
- - "~>"
|
179
207
|
- !ruby/object:Gem::Version
|
180
208
|
version: '3.0'
|
181
209
|
- !ruby/object:Gem::Dependency
|
182
210
|
name: resque
|
183
211
|
requirement: !ruby/object:Gem::Requirement
|
184
212
|
requirements:
|
185
|
-
- - ~>
|
213
|
+
- - "~>"
|
186
214
|
- !ruby/object:Gem::Version
|
187
215
|
version: '1.25'
|
188
216
|
type: :runtime
|
189
217
|
prerelease: false
|
190
218
|
version_requirements: !ruby/object:Gem::Requirement
|
191
219
|
requirements:
|
192
|
-
- - ~>
|
220
|
+
- - "~>"
|
193
221
|
- !ruby/object:Gem::Version
|
194
222
|
version: '1.25'
|
195
223
|
- !ruby/object:Gem::Dependency
|
196
224
|
name: rufus-scheduler
|
197
225
|
requirement: !ruby/object:Gem::Requirement
|
198
226
|
requirements:
|
199
|
-
- - ~>
|
227
|
+
- - "~>"
|
200
228
|
- !ruby/object:Gem::Version
|
201
229
|
version: '3.0'
|
202
230
|
type: :runtime
|
203
231
|
prerelease: false
|
204
232
|
version_requirements: !ruby/object:Gem::Requirement
|
205
233
|
requirements:
|
206
|
-
- - ~>
|
234
|
+
- - "~>"
|
207
235
|
- !ruby/object:Gem::Version
|
208
236
|
version: '3.0'
|
209
|
-
description:
|
210
|
-
|
211
|
-
|
237
|
+
description: |2
|
238
|
+
Light weight job scheduling on top of Resque.
|
239
|
+
Adds methods enqueue_at/enqueue_in to schedule jobs in the future.
|
240
|
+
Also supports queueing jobs on a fixed, cron-like schedule.
|
212
241
|
email:
|
213
242
|
- bvandenbos@gmail.com
|
214
243
|
executables:
|
@@ -216,15 +245,15 @@ executables:
|
|
216
245
|
extensions: []
|
217
246
|
extra_rdoc_files: []
|
218
247
|
files:
|
219
|
-
- .gitignore
|
220
|
-
- .rubocop.yml
|
221
|
-
- .rubocop_todo.yml
|
222
|
-
- .simplecov
|
223
|
-
- .travis.yml
|
224
|
-
- .vagrant-provision-as-vagrant.sh
|
225
|
-
- .vagrant-provision.sh
|
226
|
-
- .vagrant-skel/bash_profile
|
227
|
-
- .vagrant-skel/bashrc
|
248
|
+
- ".gitignore"
|
249
|
+
- ".rubocop.yml"
|
250
|
+
- ".rubocop_todo.yml"
|
251
|
+
- ".simplecov"
|
252
|
+
- ".travis.yml"
|
253
|
+
- ".vagrant-provision-as-vagrant.sh"
|
254
|
+
- ".vagrant-provision.sh"
|
255
|
+
- ".vagrant-skel/bash_profile"
|
256
|
+
- ".vagrant-skel/bashrc"
|
228
257
|
- AUTHORS.md
|
229
258
|
- CONTRIBUTING.md
|
230
259
|
- Gemfile
|
@@ -285,7 +314,6 @@ files:
|
|
285
314
|
- test/scheduler_setup_test.rb
|
286
315
|
- test/scheduler_task_test.rb
|
287
316
|
- test/scheduler_test.rb
|
288
|
-
- test/support/redis_instance.rb
|
289
317
|
- test/test_helper.rb
|
290
318
|
- test/util_test.rb
|
291
319
|
homepage: http://github.com/resque/resque-scheduler
|
@@ -298,17 +326,17 @@ require_paths:
|
|
298
326
|
- lib
|
299
327
|
required_ruby_version: !ruby/object:Gem::Requirement
|
300
328
|
requirements:
|
301
|
-
- -
|
329
|
+
- - ">="
|
302
330
|
- !ruby/object:Gem::Version
|
303
331
|
version: '0'
|
304
332
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
305
333
|
requirements:
|
306
|
-
- -
|
334
|
+
- - ">="
|
307
335
|
- !ruby/object:Gem::Version
|
308
336
|
version: '0'
|
309
337
|
requirements: []
|
310
338
|
rubyforge_project:
|
311
|
-
rubygems_version: 2.
|
339
|
+
rubygems_version: 2.5.1
|
312
340
|
signing_key:
|
313
341
|
specification_version: 4
|
314
342
|
summary: Light weight job scheduling on top of Resque
|
@@ -324,6 +352,6 @@ test_files:
|
|
324
352
|
- test/scheduler_setup_test.rb
|
325
353
|
- test/scheduler_task_test.rb
|
326
354
|
- test/scheduler_test.rb
|
327
|
-
- test/support/redis_instance.rb
|
328
355
|
- test/test_helper.rb
|
329
356
|
- test/util_test.rb
|
357
|
+
has_rdoc:
|
@@ -1,133 +0,0 @@
|
|
1
|
-
# vim:fileencoding=utf-8
|
2
|
-
require 'socket'
|
3
|
-
require 'timeout'
|
4
|
-
require 'fileutils'
|
5
|
-
|
6
|
-
class RedisInstance
|
7
|
-
class << self
|
8
|
-
@running = false
|
9
|
-
@port = nil
|
10
|
-
@pid = nil
|
11
|
-
@waiting = false
|
12
|
-
|
13
|
-
def run_if_needed!
|
14
|
-
run! unless @running
|
15
|
-
end
|
16
|
-
|
17
|
-
def run!
|
18
|
-
ensure_redis_server_present!
|
19
|
-
ensure_pid_directory
|
20
|
-
reassign_redis_clients
|
21
|
-
start_redis_server
|
22
|
-
post_boot_waiting_and_such
|
23
|
-
|
24
|
-
@running = true
|
25
|
-
end
|
26
|
-
|
27
|
-
def stop!
|
28
|
-
$stdout.puts "Sending TERM to Redis (#{pid})..." if $stdout.tty?
|
29
|
-
Process.kill('TERM', pid)
|
30
|
-
|
31
|
-
@port = nil
|
32
|
-
@running = false
|
33
|
-
@pid = nil
|
34
|
-
end
|
35
|
-
|
36
|
-
private
|
37
|
-
|
38
|
-
def post_boot_waiting_and_such
|
39
|
-
wait_for_pid
|
40
|
-
puts "Booted isolated Redis on #{port} with PID #{pid}."
|
41
|
-
|
42
|
-
wait_for_redis_boot
|
43
|
-
|
44
|
-
# Ensure we tear down Redis on Ctrl+C / test failure.
|
45
|
-
at_exit { stop! }
|
46
|
-
end
|
47
|
-
|
48
|
-
def ensure_redis_server_present!
|
49
|
-
unless system('redis-server -v')
|
50
|
-
fail "** can't find `redis-server` in your path"
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def wait_for_redis_boot
|
55
|
-
Timeout.timeout(10) do
|
56
|
-
loop do
|
57
|
-
begin
|
58
|
-
break if Resque.redis.ping == 'PONG'
|
59
|
-
rescue Redis::CannotConnectError
|
60
|
-
@waiting = true
|
61
|
-
end
|
62
|
-
end
|
63
|
-
@waiting = false
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def ensure_pid_directory
|
68
|
-
FileUtils.mkdir_p(File.dirname(pid_file))
|
69
|
-
end
|
70
|
-
|
71
|
-
def reassign_redis_clients
|
72
|
-
Resque.redis = Redis.new(
|
73
|
-
hostname: '127.0.0.1', port: port, thread_safe: true
|
74
|
-
)
|
75
|
-
end
|
76
|
-
|
77
|
-
def start_redis_server
|
78
|
-
IO.popen('redis-server -', 'w+') do |server|
|
79
|
-
server.write(config)
|
80
|
-
server.close_write
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def pid
|
85
|
-
@pid ||= File.read(pid_file).to_i
|
86
|
-
end
|
87
|
-
|
88
|
-
def wait_for_pid
|
89
|
-
Timeout.timeout(10) do
|
90
|
-
loop { break if File.exist?(pid_file) }
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
def port
|
95
|
-
@port ||= random_port
|
96
|
-
end
|
97
|
-
|
98
|
-
def pid_file
|
99
|
-
'/tmp/redis-scheduler-test.pid'
|
100
|
-
end
|
101
|
-
|
102
|
-
def config
|
103
|
-
<<-EOF
|
104
|
-
daemonize yes
|
105
|
-
pidfile #{pid_file}
|
106
|
-
port #{port}
|
107
|
-
EOF
|
108
|
-
end
|
109
|
-
|
110
|
-
# Returns a random port in the upper (10000-65535) range.
|
111
|
-
def random_port
|
112
|
-
ports = (10_000..65_535).to_a
|
113
|
-
|
114
|
-
loop do
|
115
|
-
port = ports[rand(ports.size)]
|
116
|
-
return port if port_available?('127.0.0.1', port)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
def port_available?(ip, port, seconds = 1)
|
121
|
-
Timeout.timeout(seconds) do
|
122
|
-
begin
|
123
|
-
TCPSocket.new(ip, port).close
|
124
|
-
false
|
125
|
-
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
|
126
|
-
true
|
127
|
-
end
|
128
|
-
end
|
129
|
-
rescue Timeout::Error
|
130
|
-
true
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|