resque-scheduler 4.3.0 → 4.7.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.

@@ -1,9 +1,9 @@
1
1
  <h1>Delayed Jobs</h1>
2
- <%- size = resque.delayed_queue_schedule_size %>
2
+ <% size = resque.delayed_queue_schedule_size %>
3
3
 
4
4
  <%= scheduler_view :search_form, layout: false %>
5
5
 
6
- <p style="font-color: red; font-weight: bold;">
6
+ <p style="color: red; font-weight: bold;">
7
7
  <%= @error_message %>
8
8
  </p>
9
9
 
@@ -46,7 +46,7 @@
46
46
  <td><%= h(show_job_arguments(job['args'])) if job && delayed_timestamp_size == 1 %></td>
47
47
  <td>
48
48
  <% if job %>
49
- <a href="<%=u URI("/delayed/jobs/#{job['class']}?args=" + URI.encode(job['args'].to_json)) %>">All schedules</a>
49
+ <a href="<%= u URI("/delayed/jobs/#{CGI.escape(job['class'])}?args=" + CGI.escape(job['args'].to_json)) %>">All schedules</a>
50
50
  <% end %>
51
51
  </td>
52
52
  </tr>
@@ -55,7 +55,7 @@
55
55
 
56
56
  <% if size > 0 %>
57
57
  <br>
58
- <form method="POST" action="<%=u 'delayed/clear'%>" class='clear-delayed'>
58
+ <form method="POST" action="<%= u 'delayed/clear' %>" class='clear-delayed'>
59
59
  <input type='submit' name='' value='Clear Delayed Jobs' />
60
60
  </form>
61
61
  <% end %>
@@ -13,7 +13,7 @@
13
13
  <% jobs.each do |job| %>
14
14
  <tr>
15
15
  <td class='class'><%= job['class'] %></td>
16
- <td class='args'><%=h show_job_arguments(job['args']) %></td>
16
+ <td class='args'><%= h show_job_arguments(job['args']) %></td>
17
17
  </tr>
18
18
  <% end %>
19
19
  <% if jobs.empty? %>
@@ -8,7 +8,7 @@
8
8
  <br/> Current master: <%= Resque.redis.get(Resque::Scheduler.master_lock.key) %>
9
9
  </p>
10
10
  <p class='intro'>
11
- The highlighted jobs are skipped for current environment.
11
+ The highlighted jobs are skipped for current environment.
12
12
  </p>
13
13
  <div style="overflow-y: auto; width:100%; padding: 0px 5px;">
14
14
  <table>
@@ -29,7 +29,7 @@
29
29
  <% Resque.schedule.keys.sort.each_with_index do |name, index| %>
30
30
  <% config = Resque.schedule[name] %>
31
31
  <tr style="<%= scheduled_in_this_env?(name) ? '' : 'color: #9F6000;background: #FEEFB3;' %>">
32
- <td style="padding-left: 15px;"><%= index+ 1 %>.</td>
32
+ <td style="padding-left: 15px;"><%= index + 1 %>.</td>
33
33
  <% if Resque::Scheduler.dynamic %>
34
34
  <td style="padding-top: 12px; padding-bottom: 2px; width: 10px">
35
35
  <form action="<%= u "/schedule" %>" method="post" style="margin-left: 0">
@@ -33,7 +33,6 @@
33
33
  </tr>
34
34
  <% end %>
35
35
  </table>
36
- </h1>
37
36
 
38
37
  <% queued = @jobs.select { |j| j['where_at'] == 'queued' } %>
39
38
  <h1>Queued jobs</h1>
@@ -68,5 +67,3 @@
68
67
  </tr>
69
68
  <% end %>
70
69
  </table>
71
-
72
-
@@ -1,8 +1,4 @@
1
1
  <form method="POST" action="<%= u 'delayed/search' %>">
2
- <input type='input' name='search' value="<%= params[:search] %>"/>
2
+ <input type='input' name='search' value="<%= h params[:search] %>"/>
3
3
  <input type='submit' value='Search'/>
4
4
  </form>
5
-
6
-
7
-
8
-
@@ -87,7 +87,7 @@ module Resque
87
87
  def delayed_jobs_klass
88
88
  begin
89
89
  klass = Resque::Scheduler::Util.constantize(params[:klass])
90
- @args = JSON.load(URI.decode(params[:args]))
90
+ @args = JSON.load(CGI.unescape(params[:args]))
91
91
  @timestamps = Resque.scheduled_at(klass, *@args)
92
92
  rescue
93
93
  @timestamps = []
@@ -10,13 +10,13 @@ module Resque
10
10
  end
11
11
 
12
12
  # For all signals, set the shutdown flag and wait for current
13
- # poll/enqueing to finish (should be almost instant). In the
13
+ # poll/enqueuing to finish (should be almost instant). In the
14
14
  # case of sleeping, exit immediately.
15
15
  def register_signal_handlers
16
16
  (Signal.list.keys & %w(INT TERM USR1 USR2 QUIT)).each do |sig|
17
17
  trap(sig) do
18
18
  signal_queue << sig
19
- # break sleep in the primary scheduler thread, alowing
19
+ # break sleep in the primary scheduler thread, allowing
20
20
  # the signal queue to get processed as soon as possible.
21
21
  @th.wakeup if @th && @th.alive?
22
22
  end
@@ -4,7 +4,7 @@ module Resque
4
4
  module Scheduler
5
5
  class Util
6
6
  # In order to upgrade to resque(1.25) which has deprecated following
7
- # methods, we just added these usefull helpers back to use in Resque
7
+ # methods, we just added these useful helpers back to use in Resque
8
8
  # Scheduler. refer to:
9
9
  # https://github.com/resque/resque-scheduler/pull/273
10
10
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Resque
4
4
  module Scheduler
5
- VERSION = '4.3.0'.freeze
5
+ VERSION = '4.7.0'.freeze
6
6
  end
7
7
  end
@@ -1,5 +1,6 @@
1
1
  # vim:fileencoding=utf-8
2
2
 
3
+ require 'redis/errors'
3
4
  require 'rufus/scheduler'
4
5
  require_relative 'scheduler/configuration'
5
6
  require_relative 'scheduler/locking'
@@ -13,6 +14,9 @@ module Resque
13
14
  autoload :Extension, 'resque/scheduler/extension'
14
15
  autoload :Util, 'resque/scheduler/util'
15
16
  autoload :VERSION, 'resque/scheduler/version'
17
+ INTERMITTENT_ERRORS = [
18
+ Errno::EAGAIN, Errno::ECONNRESET, Redis::CannotConnectError, Redis::TimeoutError
19
+ ].freeze
16
20
 
17
21
  private
18
22
 
@@ -44,13 +48,7 @@ module Resque
44
48
  $stdout.sync = true
45
49
  $stderr.sync = true
46
50
 
47
- # Load the schedule into rufus
48
- # If dynamic is set, load that schedule otherwise use normal load
49
- if dynamic
50
- reload_schedule!
51
- else
52
- load_schedule!
53
- end
51
+ was_master = nil
54
52
 
55
53
  begin
56
54
  @th = Thread.current
@@ -58,11 +56,21 @@ module Resque
58
56
  # Now start the scheduling part of the loop.
59
57
  loop do
60
58
  begin
61
- if master?
59
+ # Check on changes to master/child
60
+ @am_master = master?
61
+ if am_master != was_master
62
+ procline am_master ? 'Master scheduler' : 'Child scheduler'
63
+
64
+ # Load schedule because changed
65
+ reload_schedule!
66
+ end
67
+
68
+ if am_master
62
69
  handle_delayed_items
63
70
  update_schedule if dynamic
64
71
  end
65
- rescue Errno::EAGAIN, Errno::ECONNRESET, Redis::CannotConnectError => e
72
+ was_master = am_master
73
+ rescue *INTERMITTENT_ERRORS => e
66
74
  log! e.message
67
75
  release_master_lock
68
76
  end
@@ -99,7 +107,7 @@ module Resque
99
107
  Resque.schedule.each do |name, config|
100
108
  load_schedule_job(name, config)
101
109
  end
102
- Resque.redis.del(:schedules_changed)
110
+ Resque.redis.del(:schedules_changed) if am_master && dynamic
103
111
  procline 'Schedules Loaded'
104
112
  end
105
113
 
@@ -141,11 +149,7 @@ module Resque
141
149
  args = [args, nil, job: true] if args.is_a?(::String)
142
150
 
143
151
  job = rufus_scheduler.send(interval_type, *args) do
144
- if master?
145
- log! "queueing #{config['class']} (#{name})"
146
- Resque.last_enqueued_at(name, Time.now.to_s)
147
- enqueue(config)
148
- end
152
+ enqueue_recurring(name, config)
149
153
  end
150
154
  @scheduled_jobs[name] = job
151
155
  interval_defined = true
@@ -206,7 +210,7 @@ module Resque
206
210
  loop do
207
211
  handle_shutdown do
208
212
  # Continually check that it is still the master
209
- item = enqueue_next_item(timestamp) if master?
213
+ item = enqueue_next_item(timestamp) if am_master
210
214
  end
211
215
  # continue processing until there are no more ready items in this
212
216
  # timestamp
@@ -247,7 +251,7 @@ module Resque
247
251
  if job_klass && job_klass != 'Resque::Job'
248
252
  # The custom job class API must offer a static "scheduled" method. If
249
253
  # the custom job class can not be constantized (via a requeue call
250
- # from the web perhaps), fall back to enqueing normally via
254
+ # from the web perhaps), fall back to enqueuing normally via
251
255
  # Resque::Job.create.
252
256
  begin
253
257
  Resque::Scheduler::Util.constantize(job_klass).scheduled(
@@ -371,7 +375,12 @@ module Resque
371
375
  true
372
376
  end
373
377
 
378
+ def stop_rufus_scheduler
379
+ rufus_scheduler.shutdown(:wait)
380
+ end
381
+
374
382
  def before_shutdown
383
+ stop_rufus_scheduler
375
384
  release_master_lock
376
385
  end
377
386
 
@@ -417,6 +426,14 @@ module Resque
417
426
 
418
427
  private
419
428
 
429
+ def enqueue_recurring(name, config)
430
+ if am_master
431
+ log! "queueing #{config['class']} (#{name})"
432
+ enqueue(config)
433
+ Resque.last_enqueued_at(name, Time.now.to_s)
434
+ end
435
+ end
436
+
420
437
  def app_str
421
438
  app_name ? "[#{app_name}]" : ''
422
439
  end
@@ -432,6 +449,11 @@ module Resque
432
449
  def internal_name
433
450
  "resque-scheduler-#{Resque::Scheduler::VERSION}"
434
451
  end
452
+
453
+ def am_master
454
+ @am_master = master? unless defined?(@am_master)
455
+ @am_master
456
+ end
435
457
  end
436
458
  end
437
459
  end
@@ -11,12 +11,14 @@ Gem::Specification.new do |spec|
11
11
  Simon Eskildsen
12
12
  Ryan Biesemeyer
13
13
  Dan Buch
14
+ Michael Bianco
14
15
  EOF
15
16
  spec.email = %w(
16
17
  bvandenbos@gmail.com
17
18
  sirup@sirupsen.com
18
19
  ryan@yaauie.com
19
20
  dan@meatballhat.com
21
+ mike@mikebian.co
20
22
  )
21
23
  spec.summary = 'Light weight job scheduling on top of Resque'
22
24
  spec.description = <<-DESCRIPTION
@@ -24,13 +26,16 @@ Gem::Specification.new do |spec|
24
26
  Adds methods enqueue_at/enqueue_in to schedule jobs in the future.
25
27
  Also supports queueing jobs on a fixed, cron-like schedule.
26
28
  DESCRIPTION
27
- spec.homepage = 'http://github.com/resque/resque-scheduler'
29
+ spec.homepage = 'https://github.com/resque/resque-scheduler'
28
30
  spec.license = 'MIT'
31
+ spec.metadata['rubygems_mfa_required'] = 'true'
32
+
33
+ spec.required_ruby_version = '>= 2.3.0'
29
34
 
30
35
  spec.files = `git ls-files -z`.split("\0").reject do |f|
31
36
  f.match(%r{^(test|spec|features|examples|bin|tasks)/}) ||
32
- f.match(/^(Vagrantfile|Gemfile\.lock|appveyor\.yml)/) ||
33
- f.match(/^\.(rubocop|simplecov|travis|vagrant|gitignore)/)
37
+ f.match(/^(Vagrantfile|Gemfile\.lock)/) ||
38
+ f.match(/^\.(rubocop|simplecov|vagrant|gitignore)/)
34
39
  end
35
40
  spec.bindir = 'exe'
36
41
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
@@ -38,7 +43,6 @@ Gem::Specification.new do |spec|
38
43
 
39
44
  spec.add_development_dependency 'bundler'
40
45
  spec.add_development_dependency 'json'
41
- spec.add_development_dependency 'kramdown'
42
46
  spec.add_development_dependency 'minitest'
43
47
  spec.add_development_dependency 'mocha'
44
48
  spec.add_development_dependency 'pry'
@@ -47,13 +51,16 @@ Gem::Specification.new do |spec|
47
51
  spec.add_development_dependency 'simplecov'
48
52
  spec.add_development_dependency 'test-unit'
49
53
  spec.add_development_dependency 'yard'
54
+ spec.add_development_dependency 'timecop'
50
55
 
51
56
  # We pin rubocop because new cops have a tendency to result in false-y
52
57
  # positives for new contributors, which is not a nice experience.
53
58
  spec.add_development_dependency 'rubocop', '~> 0.40.0'
54
59
 
55
60
  spec.add_runtime_dependency 'mono_logger', '~> 1.0'
56
- spec.add_runtime_dependency 'redis', '~> 3.3'
57
- spec.add_runtime_dependency 'resque', '~> 1.26'
58
- spec.add_runtime_dependency 'rufus-scheduler', '~> 3.2'
61
+ spec.add_runtime_dependency 'redis', '>= 3.3'
62
+ spec.add_runtime_dependency 'resque', '>= 1.27'
63
+ # rufus-scheduler v3.7 causes a failure in test/multi_process_test.rb
64
+ # rufus-scheduler v3.3 is missing a to_local method which fails tests
65
+ spec.add_runtime_dependency 'rufus-scheduler', '~> 3.2', '!= 3.3'
59
66
  end
metadata CHANGED
@@ -1,17 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-scheduler
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.0
4
+ version: 4.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben VandenBos
8
8
  - Simon Eskildsen
9
9
  - Ryan Biesemeyer
10
10
  - Dan Buch
11
- autorequire:
11
+ - Michael Bianco
12
+ autorequire:
12
13
  bindir: exe
13
14
  cert_chain: []
14
- date: 2016-06-26 00:00:00.000000000 Z
15
+ date: 2022-10-07 00:00:00.000000000 Z
15
16
  dependencies:
16
17
  - !ruby/object:Gem::Dependency
17
18
  name: bundler
@@ -42,7 +43,7 @@ dependencies:
42
43
  - !ruby/object:Gem::Version
43
44
  version: '0'
44
45
  - !ruby/object:Gem::Dependency
45
- name: kramdown
46
+ name: minitest
46
47
  requirement: !ruby/object:Gem::Requirement
47
48
  requirements:
48
49
  - - ">="
@@ -56,7 +57,7 @@ dependencies:
56
57
  - !ruby/object:Gem::Version
57
58
  version: '0'
58
59
  - !ruby/object:Gem::Dependency
59
- name: minitest
60
+ name: mocha
60
61
  requirement: !ruby/object:Gem::Requirement
61
62
  requirements:
62
63
  - - ">="
@@ -70,7 +71,7 @@ dependencies:
70
71
  - !ruby/object:Gem::Version
71
72
  version: '0'
72
73
  - !ruby/object:Gem::Dependency
73
- name: mocha
74
+ name: pry
74
75
  requirement: !ruby/object:Gem::Requirement
75
76
  requirements:
76
77
  - - ">="
@@ -84,7 +85,7 @@ dependencies:
84
85
  - !ruby/object:Gem::Version
85
86
  version: '0'
86
87
  - !ruby/object:Gem::Dependency
87
- name: pry
88
+ name: rack-test
88
89
  requirement: !ruby/object:Gem::Requirement
89
90
  requirements:
90
91
  - - ">="
@@ -98,7 +99,7 @@ dependencies:
98
99
  - !ruby/object:Gem::Version
99
100
  version: '0'
100
101
  - !ruby/object:Gem::Dependency
101
- name: rack-test
102
+ name: rake
102
103
  requirement: !ruby/object:Gem::Requirement
103
104
  requirements:
104
105
  - - ">="
@@ -112,7 +113,7 @@ dependencies:
112
113
  - !ruby/object:Gem::Version
113
114
  version: '0'
114
115
  - !ruby/object:Gem::Dependency
115
- name: rake
116
+ name: simplecov
116
117
  requirement: !ruby/object:Gem::Requirement
117
118
  requirements:
118
119
  - - ">="
@@ -126,7 +127,7 @@ dependencies:
126
127
  - !ruby/object:Gem::Version
127
128
  version: '0'
128
129
  - !ruby/object:Gem::Dependency
129
- name: simplecov
130
+ name: test-unit
130
131
  requirement: !ruby/object:Gem::Requirement
131
132
  requirements:
132
133
  - - ">="
@@ -140,7 +141,7 @@ dependencies:
140
141
  - !ruby/object:Gem::Version
141
142
  version: '0'
142
143
  - !ruby/object:Gem::Dependency
143
- name: test-unit
144
+ name: yard
144
145
  requirement: !ruby/object:Gem::Requirement
145
146
  requirements:
146
147
  - - ">="
@@ -154,7 +155,7 @@ dependencies:
154
155
  - !ruby/object:Gem::Version
155
156
  version: '0'
156
157
  - !ruby/object:Gem::Dependency
157
- name: yard
158
+ name: timecop
158
159
  requirement: !ruby/object:Gem::Requirement
159
160
  requirements:
160
161
  - - ">="
@@ -199,30 +200,30 @@ dependencies:
199
200
  name: redis
200
201
  requirement: !ruby/object:Gem::Requirement
201
202
  requirements:
202
- - - "~>"
203
+ - - ">="
203
204
  - !ruby/object:Gem::Version
204
205
  version: '3.3'
205
206
  type: :runtime
206
207
  prerelease: false
207
208
  version_requirements: !ruby/object:Gem::Requirement
208
209
  requirements:
209
- - - "~>"
210
+ - - ">="
210
211
  - !ruby/object:Gem::Version
211
212
  version: '3.3'
212
213
  - !ruby/object:Gem::Dependency
213
214
  name: resque
214
215
  requirement: !ruby/object:Gem::Requirement
215
216
  requirements:
216
- - - "~>"
217
+ - - ">="
217
218
  - !ruby/object:Gem::Version
218
- version: '1.26'
219
+ version: '1.27'
219
220
  type: :runtime
220
221
  prerelease: false
221
222
  version_requirements: !ruby/object:Gem::Requirement
222
223
  requirements:
223
- - - "~>"
224
+ - - ">="
224
225
  - !ruby/object:Gem::Version
225
- version: '1.26'
226
+ version: '1.27'
226
227
  - !ruby/object:Gem::Dependency
227
228
  name: rufus-scheduler
228
229
  requirement: !ruby/object:Gem::Requirement
@@ -230,6 +231,9 @@ dependencies:
230
231
  - - "~>"
231
232
  - !ruby/object:Gem::Version
232
233
  version: '3.2'
234
+ - - "!="
235
+ - !ruby/object:Gem::Version
236
+ version: '3.3'
233
237
  type: :runtime
234
238
  prerelease: false
235
239
  version_requirements: !ruby/object:Gem::Requirement
@@ -237,6 +241,9 @@ dependencies:
237
241
  - - "~>"
238
242
  - !ruby/object:Gem::Version
239
243
  version: '3.2'
244
+ - - "!="
245
+ - !ruby/object:Gem::Version
246
+ version: '3.3'
240
247
  description: |2
241
248
  Light weight job scheduling on top of Resque.
242
249
  Adds methods enqueue_at/enqueue_in to schedule jobs in the future.
@@ -246,16 +253,22 @@ email:
246
253
  - sirup@sirupsen.com
247
254
  - ryan@yaauie.com
248
255
  - dan@meatballhat.com
256
+ - mike@mikebian.co
249
257
  executables:
250
258
  - resque-scheduler
251
259
  extensions: []
252
260
  extra_rdoc_files: []
253
261
  files:
262
+ - ".github/dependabot.yml"
263
+ - ".github/funding.yml"
264
+ - ".github/workflows/codeql-analysis.yml"
265
+ - ".github/workflows/rubocop.yml"
266
+ - ".github/workflows/ruby.yml"
254
267
  - AUTHORS.md
268
+ - CHANGELOG.md
255
269
  - CODE_OF_CONDUCT.md
256
270
  - CONTRIBUTING.md
257
271
  - Gemfile
258
- - HISTORY.md
259
272
  - LICENSE
260
273
  - README.md
261
274
  - Rakefile
@@ -289,11 +302,12 @@ files:
289
302
  - lib/resque/scheduler/util.rb
290
303
  - lib/resque/scheduler/version.rb
291
304
  - resque-scheduler.gemspec
292
- homepage: http://github.com/resque/resque-scheduler
305
+ homepage: https://github.com/resque/resque-scheduler
293
306
  licenses:
294
307
  - MIT
295
- metadata: {}
296
- post_install_message:
308
+ metadata:
309
+ rubygems_mfa_required: 'true'
310
+ post_install_message:
297
311
  rdoc_options: []
298
312
  require_paths:
299
313
  - lib
@@ -301,17 +315,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
301
315
  requirements:
302
316
  - - ">="
303
317
  - !ruby/object:Gem::Version
304
- version: '0'
318
+ version: 2.3.0
305
319
  required_rubygems_version: !ruby/object:Gem::Requirement
306
320
  requirements:
307
321
  - - ">="
308
322
  - !ruby/object:Gem::Version
309
323
  version: '0'
310
324
  requirements: []
311
- rubyforge_project:
312
- rubygems_version: 2.5.1
313
- signing_key:
325
+ rubygems_version: 3.1.2
326
+ signing_key:
314
327
  specification_version: 4
315
328
  summary: Light weight job scheduling on top of Resque
316
329
  test_files: []
317
- has_rdoc: