resque-scheduler 2.5.0 → 2.5.1

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.

@@ -18,7 +18,7 @@ CaseEquality:
18
18
  Enabled: false
19
19
 
20
20
  ClassLength:
21
- Max: 303
21
+ Max: 318
22
22
 
23
23
  ClassVars:
24
24
  Enabled: false
data/HISTORY.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Resque Scheduler History / ChangeLog / Release Notes
2
2
 
3
+ ## 2.5.1 (2014-02-09)
4
+ * Make signal handling (really) Ruby 2 compatible
5
+
3
6
  ## 2.5.0 (2014-02-09)
4
7
  * Use `logger.error` when logging errors from `handle_errors`
5
8
  * Added search feature to the Delayed tab in Resque Web
@@ -12,6 +12,12 @@ module Resque
12
12
  yield self
13
13
  end
14
14
 
15
+ attr_writer :signal_queue
16
+
17
+ def signal_queue
18
+ @signal_queue ||= []
19
+ end
20
+
15
21
  # Used in `#load_schedule_job`
16
22
  attr_writer :env
17
23
 
@@ -110,37 +116,47 @@ module Resque
110
116
  load_schedule!
111
117
  end
112
118
 
113
- @th = Thread.current
114
-
115
- # Now start the scheduling part of the loop.
116
- loop do
117
- if is_master?
118
- begin
119
- handle_delayed_items
120
- update_schedule if dynamic
121
- rescue Errno::EAGAIN, Errno::ECONNRESET => e
122
- warn e.message
119
+ begin
120
+ @th = Thread.current
121
+
122
+ # Now start the scheduling part of the loop.
123
+ loop do
124
+ if is_master?
125
+ begin
126
+ handle_delayed_items
127
+ update_schedule if dynamic
128
+ rescue Errno::EAGAIN, Errno::ECONNRESET => e
129
+ log! e.message
130
+ end
123
131
  end
132
+ handle_signals
133
+ poll_sleep
124
134
  end
125
- poll_sleep
126
- end
127
135
 
128
- # never gets here.
136
+ rescue Interrupt
137
+ log 'Exiting'
138
+ end
129
139
  end
130
140
 
131
141
  # For all signals, set the shutdown flag and wait for current
132
- # poll/enqueing to finish (should be almost istant). In the
142
+ # poll/enqueing to finish (should be almost instant). In the
133
143
  # case of sleeping, exit immediately.
134
144
  def register_signal_handlers
135
- trap("TERM") { shutdown }
136
- trap("INT") { shutdown }
145
+ %w(INT TERM USR1 USR2 QUIT).each do |sig|
146
+ trap(sig) { signal_queue << sig }
147
+ end
148
+ end
137
149
 
138
- begin
139
- trap('QUIT') { shutdown }
140
- trap('USR1') { print_schedule }
141
- trap('USR2') { reload_schedule! }
142
- rescue ArgumentError
143
- warn "Signals QUIT and USR1 and USR2 not supported."
150
+ def handle_signals
151
+ loop do
152
+ sig = signal_queue.shift
153
+ break unless sig
154
+ log! "Got #{sig} signal"
155
+ case sig
156
+ when 'INT', 'TERM', 'QUIT' then shutdown
157
+ when 'USR1' then print_schedule
158
+ when 'USR2' then reload_schedule!
159
+ end
144
160
  end
145
161
  end
146
162
 
@@ -1,5 +1,5 @@
1
1
  # vim:fileencoding=utf-8
2
2
 
3
3
  module ResqueScheduler
4
- VERSION = '2.5.0'
4
+ VERSION = '2.5.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-scheduler
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.5.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -256,7 +256,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
256
256
  version: '0'
257
257
  segments:
258
258
  - 0
259
- hash: -949662411159458522
259
+ hash: 322946193888526441
260
260
  required_rubygems_version: !ruby/object:Gem::Requirement
261
261
  none: false
262
262
  requirements:
@@ -265,7 +265,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
265
265
  version: '0'
266
266
  segments:
267
267
  - 0
268
- hash: -949662411159458522
268
+ hash: 322946193888526441
269
269
  requirements: []
270
270
  rubyforge_project:
271
271
  rubygems_version: 1.8.23