resque 2.7.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/HISTORY.md +34 -0
- data/README.markdown +22 -21
- data/Rakefile +27 -1
- data/lib/active_job/queue_adapters/resque_adapter.rb +54 -0
- data/lib/resque/failure/redis.rb +1 -1
- data/lib/resque/helpers.rb +13 -8
- data/lib/resque/railtie.rb +6 -0
- data/lib/resque/server/views/key_sets.erb +1 -1
- data/lib/resque/tasks.rb +5 -1
- data/lib/resque/version.rb +1 -1
- data/lib/resque/web_runner.rb +15 -6
- data/lib/resque/worker.rb +32 -5
- data/lib/resque.rb +15 -1
- metadata +50 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e48882e2b37c0256d7fb756dd585af487b5fd3d1161aa8e9aa0e06780ab51840
|
|
4
|
+
data.tar.gz: dd5cf203cb498beb074acf2d024343a948ad6658d52e9fc645c01450369176b9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 259841b283671d350964b422526e1ef05ef789f72a2c03afea5a74cd15d7f162dfd32ce2dce54d058cc1d62ea859603ba0f6f6e45a7da017d0f2a36322212dcc
|
|
7
|
+
data.tar.gz: 4bc3a3159deef3f51ba4546c8c23cc2203e0b127558a6beb84f502d8668122feaf2e61ba7640a1292d1c790a1b77c9590d62ad1afbabad950a660feb55dc9351
|
data/HISTORY.md
CHANGED
|
@@ -1,3 +1,37 @@
|
|
|
1
|
+
## 3.0.1
|
|
2
|
+
|
|
3
|
+
### Fixed
|
|
4
|
+
|
|
5
|
+
* resque-web: Fix reflected XSS in the key sets endpoint (#1942)
|
|
6
|
+
* Address multi_json class name deprecation warning (#1940)
|
|
7
|
+
* Update the Rails initializer docs to load Redis config with `config_for` (#1936)
|
|
8
|
+
* Add tests covering queue priority ordering with wildcards (#1930)
|
|
9
|
+
|
|
10
|
+
## 3.0.0
|
|
11
|
+
|
|
12
|
+
### Breaking Changes
|
|
13
|
+
|
|
14
|
+
* **Minimum Ruby version is now 3.0.0** - Ruby 2.x is no longer supported
|
|
15
|
+
* **Minimum Sinatra version is now 2.0** - old Sinatra versions (0.9-1.x) are no longer supported
|
|
16
|
+
* **Rack 1.x is no longer supported** - Resque now requires Rack 2.x or greater
|
|
17
|
+
* **Minimum Rails version is now 7.2** - You can use Resque without Rails, but if you use it with Rails it must be a version that is still supported
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
* Rack 3 support and switched default Rack handler to Puma (#1912)
|
|
22
|
+
* Ruby 3.4 and Rails 8.1 support (#1912 and #1906)
|
|
23
|
+
* Upstream Active Job adapter from Rails (#1906)
|
|
24
|
+
* Explicit `redis` (>= 4.0) and `base64` (~> 0.1) gem dependencies (#1922)
|
|
25
|
+
* Added `shutdown` hooks - allows plugins and adapters to know when a worker is shutting down, enabling features like Active Job Continuations (#1916, #1924)
|
|
26
|
+
* Added support for dynamic interval sleep - workers can now use a faster polling interval that automatically backs off when idle, reducing Redis load (#1920)
|
|
27
|
+
|
|
28
|
+
### Fixed
|
|
29
|
+
|
|
30
|
+
* Fix circular require from Rails ActiveJob adapter (#1906)
|
|
31
|
+
* Fix failed job `retried_at` timezone data (#1918)
|
|
32
|
+
* Fix double Redis get when checking for paused workers (#1919)
|
|
33
|
+
* Documentation cleanup (#1903, #1917)
|
|
34
|
+
|
|
1
35
|
## 2.7.0
|
|
2
36
|
|
|
3
37
|
### Fixed
|
data/README.markdown
CHANGED
|
@@ -39,15 +39,23 @@ The Resque frontend tells you what workers are doing, what workers are
|
|
|
39
39
|
not doing, what queues you're using, what's in those queues, provides
|
|
40
40
|
general usage stats, and helps you track failures.
|
|
41
41
|
|
|
42
|
-
Resque
|
|
43
|
-
We will also only be supporting Redis 3.0 and above going forward.
|
|
42
|
+
Resque 3.0 requires Ruby 3.0.0 or newer.
|
|
44
43
|
|
|
45
|
-
|
|
44
|
+
**Version Support:**
|
|
45
|
+
- Ruby: 3.0, 3.1, 3.2, 3.3, 3.4+
|
|
46
|
+
- Redis gem: 4.0+
|
|
47
|
+
- Rack: 2.x or 3.x
|
|
48
|
+
- Rails (for ActiveJob): 7.2+ (requires Ruby 3.1+ for Rails 8.0+)
|
|
46
49
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
### Resque 3.0
|
|
51
|
+
|
|
52
|
+
Resque 3.0 is a major release that modernizes the codebase with updated dependency requirements:
|
|
53
|
+
- Requires Ruby 3.0+ (drops support for Ruby 2.x)
|
|
54
|
+
- Requires redis gem 4.0+ (tested with redis gem 4.x and 5.x)
|
|
55
|
+
- Requires Sinatra 2.0+ (with Rack 2.x or 3.x support via appropriate Sinatra version)
|
|
56
|
+
- Maintains compatibility with Rails 7.2+ and ActiveJob
|
|
57
|
+
|
|
58
|
+
If you need Ruby 2.x support, please use Resque 2.x.
|
|
51
59
|
|
|
52
60
|
Example
|
|
53
61
|
-------
|
|
@@ -133,15 +141,6 @@ require 'your/app' # Include this line if you want your workers to have access t
|
|
|
133
141
|
|
|
134
142
|
#### Rails
|
|
135
143
|
|
|
136
|
-
##### Rails 7.1
|
|
137
|
-
|
|
138
|
-
If you're using Rails 7.1.x, use [rack-session version 1.0.2](https://rubygems.org/gems/rack-session/versions/1.0.2). This is because resque-web's dependency, [Sinatra, isn't compatible with rack 3.0](https://github.com/sinatra/sinatra/issues/1797), which is [required by rack-session 2.0.0](https://rubygems.org/gems/rack-session/versions/2.0.0).
|
|
139
|
-
|
|
140
|
-
```
|
|
141
|
-
gem 'rails', '~> 7.1'
|
|
142
|
-
gem 'rack-session', '~> 1.0', '>= 1.0.2'
|
|
143
|
-
```
|
|
144
|
-
|
|
145
144
|
To make resque specific changes, you can override the `resque:setup` job in `lib/tasks` (ex: `lib/tasks/resque.rake`). GitHub's setup task looks like this:
|
|
146
145
|
|
|
147
146
|
``` ruby
|
|
@@ -496,12 +495,14 @@ Here's our `config/resque.yml`:
|
|
|
496
495
|
And our initializer:
|
|
497
496
|
|
|
498
497
|
``` ruby
|
|
499
|
-
|
|
500
|
-
rails_env = ENV['RAILS_ENV'] ||
|
|
501
|
-
config_file = rails_root + '/config/resque.yml'
|
|
498
|
+
config_file = 'config/resque.yml'
|
|
499
|
+
rails_env = ENV['RAILS_ENV'] || Rails.env
|
|
502
500
|
|
|
503
|
-
resque_config = YAML::
|
|
501
|
+
resque_config = YAML::load_file(config_file)
|
|
504
502
|
Resque.redis = resque_config[rails_env]
|
|
503
|
+
|
|
504
|
+
# OR auto load with current env
|
|
505
|
+
Resque.redis = Rails.application.config_for(:resque)
|
|
505
506
|
```
|
|
506
507
|
|
|
507
508
|
Easy peasy! Why not just use `RAILS_ROOT` and `RAILS_ENV`? Because
|
|
@@ -633,7 +634,7 @@ Choose DelayedJob if:
|
|
|
633
634
|
* You like numeric priorities
|
|
634
635
|
* You're not doing a gigantic amount of jobs each day
|
|
635
636
|
* Your queue stays small and nimble
|
|
636
|
-
* There is not a lot failure / chaos
|
|
637
|
+
* There is not a lot of failure / chaos
|
|
637
638
|
* You want to easily throw anything on the queue
|
|
638
639
|
* You don't want to setup Redis
|
|
639
640
|
|
data/Rakefile
CHANGED
|
@@ -28,7 +28,33 @@ Rake::TestTask.new do |test|
|
|
|
28
28
|
test.verbose = true
|
|
29
29
|
test.libs << "test"
|
|
30
30
|
test.libs << "lib"
|
|
31
|
-
test.test_files = FileList['test/**/*_test.rb']
|
|
31
|
+
test.test_files = FileList['test/**/*_test.rb'].exclude('test/active_job/**/*')
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
Rake::TestTask.new('test:activejob') do |test|
|
|
35
|
+
test.verbose = true
|
|
36
|
+
test.libs << "test"
|
|
37
|
+
test.libs << "lib"
|
|
38
|
+
test.libs << "test/active_job"
|
|
39
|
+
test.test_files = FileList['test/active_job/cases/*_test.rb']
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
task "env:aj_integration" do
|
|
43
|
+
ENV["AJ_INTEGRATION_TESTS"] = "1"
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
Rake::TestTask.new('test:activejob:integration' => 'env:aj_integration') do |t|
|
|
47
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("3.1")
|
|
48
|
+
puts "Integration tests require Ruby 3.1 or later"
|
|
49
|
+
exit 0
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
t.description = "Run integration tests for Resque::ActiveJob::Adapter"
|
|
53
|
+
t.libs << "test"
|
|
54
|
+
t.libs << "test/active_job"
|
|
55
|
+
t.test_files = FileList["test/active_job/integration/**/*_test.rb"]
|
|
56
|
+
t.verbose = true
|
|
57
|
+
t.warning = true
|
|
32
58
|
end
|
|
33
59
|
|
|
34
60
|
if command? :kicker
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "active_support/core_ext/enumerable"
|
|
4
|
+
require "active_support/core_ext/array/access"
|
|
5
|
+
|
|
6
|
+
begin
|
|
7
|
+
require "resque-scheduler"
|
|
8
|
+
rescue LoadError
|
|
9
|
+
begin
|
|
10
|
+
require "resque_scheduler"
|
|
11
|
+
rescue LoadError
|
|
12
|
+
false
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
module ActiveJob
|
|
17
|
+
module QueueAdapters
|
|
18
|
+
remove_const(:ResqueAdapter) if defined?(ResqueAdapter)
|
|
19
|
+
|
|
20
|
+
# = Resque adapter for Active Job
|
|
21
|
+
#
|
|
22
|
+
# Resque (pronounced like "rescue") is a Redis-backed library for creating
|
|
23
|
+
# background jobs, placing those jobs on multiple queues, and processing
|
|
24
|
+
# them later.
|
|
25
|
+
#
|
|
26
|
+
# Read more about Resque {here}[https://github.com/resque/resque].
|
|
27
|
+
#
|
|
28
|
+
# To use Resque set the queue_adapter config to +:resque+.
|
|
29
|
+
#
|
|
30
|
+
# Rails.application.config.active_job.queue_adapter = :resque
|
|
31
|
+
class ResqueAdapter < ::ActiveJob::QueueAdapters::AbstractAdapter
|
|
32
|
+
def enqueue(job) # :nodoc:
|
|
33
|
+
JobWrapper.instance_variable_set(:@queue, job.queue_name)
|
|
34
|
+
Resque.enqueue_to job.queue_name, JobWrapper, job.serialize
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def enqueue_at(job, timestamp) # :nodoc:
|
|
38
|
+
unless Resque.respond_to?(:enqueue_at_with_queue)
|
|
39
|
+
raise NotImplementedError, "To be able to schedule jobs with Resque you need the " \
|
|
40
|
+
"resque-scheduler gem. Please add it to your Gemfile and run bundle install"
|
|
41
|
+
end
|
|
42
|
+
Resque.enqueue_at_with_queue job.queue_name, timestamp, JobWrapper, job.serialize
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
class JobWrapper # :nodoc:
|
|
46
|
+
class << self
|
|
47
|
+
def perform(job_data)
|
|
48
|
+
::ActiveJob::Base.execute job_data
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
data/lib/resque/failure/redis.rb
CHANGED
|
@@ -78,7 +78,7 @@ module Resque
|
|
|
78
78
|
def self.requeue(id, queue = nil)
|
|
79
79
|
check_queue(queue)
|
|
80
80
|
item = all(id)
|
|
81
|
-
item['retried_at'] = Time.now.strftime("%Y/%m/%d %H:%M:%S")
|
|
81
|
+
item['retried_at'] = UTF8Util.clean(Time.now.strftime("%Y/%m/%d %H:%M:%S %Z"))
|
|
82
82
|
data_store.update_item_in_failed_queue(id,Resque.encode(item))
|
|
83
83
|
Job.create(item['queue'], item['payload']['class'], *item['payload']['args'])
|
|
84
84
|
end
|
data/lib/resque/helpers.rb
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
require 'multi_json'
|
|
2
2
|
|
|
3
|
-
# OkJson won't work because it doesn't serialize symbols
|
|
4
|
-
# in the same way yajl and json do.
|
|
5
|
-
if MultiJson.respond_to?(:adapter)
|
|
6
|
-
raise "Please install the yajl-ruby or json gem" if MultiJson.adapter.to_s == 'MultiJson::Adapters::OkJson'
|
|
7
|
-
elsif MultiJson.respond_to?(:engine)
|
|
8
|
-
raise "Please install the yajl-ruby or json gem" if MultiJson.engine.to_s == 'MultiJson::Engines::OkJson'
|
|
9
|
-
end
|
|
10
|
-
|
|
11
3
|
module Resque
|
|
4
|
+
# multi_json renamed it's top-level constant from MultiJson to MultiJSON,
|
|
5
|
+
# keeping MultiJson as a deprecated alias until v2.0. Reference whichever name the
|
|
6
|
+
# installed version exposes so we stay compatible with future versions of multi_json
|
|
7
|
+
MultiJson = defined?(::MultiJSON) ? ::MultiJSON : ::MultiJson
|
|
8
|
+
|
|
9
|
+
# OkJson won't work because it doesn't serialize symbols
|
|
10
|
+
# in the same way yajl and json do.
|
|
11
|
+
if MultiJson.respond_to?(:adapter)
|
|
12
|
+
raise "Please install the yajl-ruby or json gem" if MultiJson.adapter.to_s.end_with?('::OkJson')
|
|
13
|
+
elsif MultiJson.respond_to?(:engine)
|
|
14
|
+
raise "Please install the yajl-ruby or json gem" if MultiJson.engine.to_s.end_with?('::OkJson')
|
|
15
|
+
end
|
|
16
|
+
|
|
12
17
|
# Methods used by various classes in Resque.
|
|
13
18
|
module Helpers
|
|
14
19
|
class DecodeException < StandardError; end
|
data/lib/resque/railtie.rb
CHANGED
|
@@ -6,5 +6,11 @@ module Resque
|
|
|
6
6
|
# redefine ths task to load the rails env
|
|
7
7
|
task "resque:setup" => :environment
|
|
8
8
|
end
|
|
9
|
+
|
|
10
|
+
initializer "resque.active_job" do
|
|
11
|
+
ActiveSupport.on_load(:active_job) do
|
|
12
|
+
require "active_job/queue_adapters/resque_adapter"
|
|
13
|
+
end
|
|
14
|
+
end
|
|
9
15
|
end
|
|
10
16
|
end
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
<p class='sub'><%= page_entries_info start = params[:start].to_i, start + 20, size = redis_get_size(key) %></p>
|
|
4
4
|
|
|
5
|
-
<h1>Key "<%= key %>" is a <%= resque.redis.type key %></h1>
|
|
5
|
+
<h1>Key "<%= escape_html(key) %>" is a <%= resque.redis.type key %></h1>
|
|
6
6
|
<table>
|
|
7
7
|
<% for row in redis_get_value_as_array(key, start) %>
|
|
8
8
|
<tr>
|
data/lib/resque/tasks.rb
CHANGED
|
@@ -17,7 +17,11 @@ namespace :resque do
|
|
|
17
17
|
|
|
18
18
|
worker.prepare
|
|
19
19
|
worker.log "Starting worker #{worker}"
|
|
20
|
-
|
|
20
|
+
# will block until a shutdown signal is received
|
|
21
|
+
worker.work(ENV["INTERVAL"],
|
|
22
|
+
max_interval: ENV['MAX_INTERVAL'],
|
|
23
|
+
min_interval: ENV['MIN_INTERVAL'],
|
|
24
|
+
backoff_interval: ENV['BACKOFF_INTERVAL'])
|
|
21
25
|
end
|
|
22
26
|
|
|
23
27
|
desc "Start multiple Resque workers. Should only be used in dev mode."
|
data/lib/resque/version.rb
CHANGED
data/lib/resque/web_runner.rb
CHANGED
|
@@ -3,6 +3,10 @@ require 'logger'
|
|
|
3
3
|
require 'optparse'
|
|
4
4
|
require 'fileutils'
|
|
5
5
|
require 'rack'
|
|
6
|
+
begin
|
|
7
|
+
require 'rackup'
|
|
8
|
+
rescue LoadError
|
|
9
|
+
end
|
|
6
10
|
require 'resque/server'
|
|
7
11
|
|
|
8
12
|
# only used with `bin/resque-web`
|
|
@@ -30,7 +34,7 @@ module Resque
|
|
|
30
34
|
|
|
31
35
|
@args = load_options(runtime_args)
|
|
32
36
|
|
|
33
|
-
@rack_handler = (s = options[:rack_handler]) ?
|
|
37
|
+
@rack_handler = (s = options[:rack_handler]) ? self.class.get_rackup_or_rack_handler.get(s) : setup_rack_handler
|
|
34
38
|
|
|
35
39
|
case option_parser.command
|
|
36
40
|
when :help
|
|
@@ -270,6 +274,10 @@ module Resque
|
|
|
270
274
|
self.class.logger
|
|
271
275
|
end
|
|
272
276
|
|
|
277
|
+
def self.get_rackup_or_rack_handler
|
|
278
|
+
defined?(::Rackup::Handler) && ::Rack.release >= '3' ? ::Rackup::Handler : ::Rack::Handler
|
|
279
|
+
end
|
|
280
|
+
|
|
273
281
|
private
|
|
274
282
|
def setup_rack_handler
|
|
275
283
|
# First try to set Rack handler via a special hook we honor
|
|
@@ -284,24 +292,25 @@ module Resque
|
|
|
284
292
|
handler = nil
|
|
285
293
|
@app.server.each do |server|
|
|
286
294
|
begin
|
|
287
|
-
handler =
|
|
295
|
+
handler = self.class.get_rackup_or_rack_handler.get(server)
|
|
288
296
|
break
|
|
289
297
|
rescue LoadError, NameError
|
|
290
298
|
next
|
|
291
299
|
end
|
|
292
300
|
end
|
|
293
|
-
raise 'No available Rack handler (e.g. WEBrick,
|
|
301
|
+
raise 'No available Rack handler (e.g. WEBrick, Puma, etc.) was found.' if handler.nil?
|
|
294
302
|
|
|
295
303
|
handler
|
|
296
304
|
|
|
297
305
|
# :server might be set explicitly to a single option like "mongrel"
|
|
298
306
|
else
|
|
299
|
-
|
|
307
|
+
self.class.get_rackup_or_rack_handler.get(@app.server)
|
|
300
308
|
end
|
|
301
309
|
|
|
302
|
-
# If all else fails, we'll use
|
|
310
|
+
# If all else fails, we'll use Puma
|
|
303
311
|
else
|
|
304
|
-
JRUBY ?
|
|
312
|
+
rack_server = JRUBY ? 'webrick' : 'puma'
|
|
313
|
+
self.class.get_rackup_or_rack_handler.get(rack_server)
|
|
305
314
|
end
|
|
306
315
|
end
|
|
307
316
|
|
data/lib/resque/worker.rb
CHANGED
|
@@ -143,6 +143,7 @@ module Resque
|
|
|
143
143
|
def initialize(*queues)
|
|
144
144
|
@shutdown = nil
|
|
145
145
|
@paused = nil
|
|
146
|
+
@cached_pause_value = nil
|
|
146
147
|
@before_first_fork_hook_ran = false
|
|
147
148
|
|
|
148
149
|
@heartbeat_thread = nil
|
|
@@ -237,20 +238,43 @@ module Resque
|
|
|
237
238
|
# The default is 5 seconds, but for a semi-active site you may
|
|
238
239
|
# want to use a smaller value.
|
|
239
240
|
#
|
|
241
|
+
# Can also be passed 3 interval floats: max, min, backoff.
|
|
242
|
+
# The actual sleep amount will float between these min/max
|
|
243
|
+
# bounds.
|
|
244
|
+
#
|
|
245
|
+
# If a job is picked up we sleep for the minimum amount of
|
|
246
|
+
# time, but as the queues empty we increase the backoff to the
|
|
247
|
+
# max interval. This prevents idle workers from hammering the
|
|
248
|
+
# redis server with lpop requests.
|
|
249
|
+
#
|
|
240
250
|
# Also accepts a block which will be passed the job as soon as it
|
|
241
251
|
# has completed processing. Useful for testing.
|
|
242
|
-
def work(interval = 5.0,
|
|
243
|
-
|
|
252
|
+
def work(interval = 5.0,
|
|
253
|
+
min_interval: nil, # defaults to interval
|
|
254
|
+
max_interval: nil, # defaults to interval
|
|
255
|
+
backoff_interval: nil, # defaults to 0.1
|
|
256
|
+
&block)
|
|
257
|
+
interval = Float(interval || 5.0)
|
|
258
|
+
max_interval = Float(max_interval || interval)
|
|
259
|
+
min_interval = Float(min_interval || interval).clamp(nil, max_interval)
|
|
260
|
+
backoff_interval = Float(backoff_interval || 0.1).clamp(nil, max_interval)
|
|
261
|
+
interval = interval.clamp(min_interval, max_interval)
|
|
244
262
|
startup
|
|
245
263
|
|
|
246
264
|
loop do
|
|
247
265
|
break if shutdown?
|
|
248
266
|
|
|
249
|
-
|
|
267
|
+
if work_one_job(&block)
|
|
268
|
+
interval = min_interval
|
|
269
|
+
else
|
|
250
270
|
state_change
|
|
251
271
|
break if interval.zero?
|
|
272
|
+
|
|
273
|
+
interval = (interval + backoff_interval)
|
|
274
|
+
.clamp(nil, max_interval)
|
|
275
|
+
|
|
252
276
|
log_with_severity :debug, "Sleeping for #{interval} seconds"
|
|
253
|
-
procline
|
|
277
|
+
procline @cached_pause_value ? "Paused" : "Waiting for #{queues.join(',')}"
|
|
254
278
|
sleep interval
|
|
255
279
|
end
|
|
256
280
|
end
|
|
@@ -260,6 +284,7 @@ module Resque
|
|
|
260
284
|
rescue Exception => exception
|
|
261
285
|
return if exception.class == SystemExit && !@child && run_at_exit_hooks
|
|
262
286
|
log_with_severity :error, "Failed to start worker : #{exception.inspect}"
|
|
287
|
+
log_with_severity :error, exception.backtrace.join("\n")
|
|
263
288
|
unregister_worker(exception)
|
|
264
289
|
run_hook :worker_exit
|
|
265
290
|
end
|
|
@@ -441,6 +466,8 @@ module Resque
|
|
|
441
466
|
def shutdown
|
|
442
467
|
log_with_severity :info, 'Exiting...'
|
|
443
468
|
@shutdown = true
|
|
469
|
+
run_hook :shutdown
|
|
470
|
+
true
|
|
444
471
|
end
|
|
445
472
|
|
|
446
473
|
# Kill the child and shutdown immediately.
|
|
@@ -579,7 +606,7 @@ module Resque
|
|
|
579
606
|
|
|
580
607
|
# are we paused?
|
|
581
608
|
def paused?
|
|
582
|
-
@paused || redis.get('pause-all-workers').to_s.strip.downcase == 'true'
|
|
609
|
+
@cached_pause_value = @paused || redis.get('pause-all-workers').to_s.strip.downcase == 'true'
|
|
583
610
|
end
|
|
584
611
|
|
|
585
612
|
# Stop processing jobs after the current one has completed (if we're
|
data/lib/resque.rb
CHANGED
|
@@ -49,7 +49,7 @@ module Resque
|
|
|
49
49
|
else
|
|
50
50
|
MultiJson.decode object
|
|
51
51
|
end
|
|
52
|
-
rescue
|
|
52
|
+
rescue MultiJson::DecodeError => e
|
|
53
53
|
raise Helpers::DecodeException, e.message, e.backtrace
|
|
54
54
|
end
|
|
55
55
|
end
|
|
@@ -316,6 +316,20 @@ module Resque
|
|
|
316
316
|
register_hook(:worker_exit, block)
|
|
317
317
|
end
|
|
318
318
|
|
|
319
|
+
# The `shutdown` hook will be run in the **child** process
|
|
320
|
+
# when the worker has received a signal to stop processing
|
|
321
|
+
#
|
|
322
|
+
# Call with a block to register a hook.
|
|
323
|
+
# Call with no arguments to return all registered hooks.
|
|
324
|
+
def shutdown(&block)
|
|
325
|
+
block ? register_hook(:shutdown, block) : hooks(:shutdown)
|
|
326
|
+
end
|
|
327
|
+
|
|
328
|
+
# Register a shutdown proc.
|
|
329
|
+
def shutdown=(block)
|
|
330
|
+
register_hook(:shutdown, block)
|
|
331
|
+
end
|
|
332
|
+
|
|
319
333
|
def to_s
|
|
320
334
|
"Resque Client connected to #{redis_id}"
|
|
321
335
|
end
|
metadata
CHANGED
|
@@ -1,18 +1,45 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: resque
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 3.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Chris Wanstrath
|
|
8
8
|
- Steve Klabnik
|
|
9
9
|
- Terence Lee
|
|
10
10
|
- Michael Bianco
|
|
11
|
-
autorequire:
|
|
12
11
|
bindir: bin
|
|
13
12
|
cert_chain: []
|
|
14
|
-
date:
|
|
13
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
15
14
|
dependencies:
|
|
15
|
+
- !ruby/object:Gem::Dependency
|
|
16
|
+
name: base64
|
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
|
18
|
+
requirements:
|
|
19
|
+
- - "~>"
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '0.1'
|
|
22
|
+
type: :runtime
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
requirements:
|
|
26
|
+
- - "~>"
|
|
27
|
+
- !ruby/object:Gem::Version
|
|
28
|
+
version: '0.1'
|
|
29
|
+
- !ruby/object:Gem::Dependency
|
|
30
|
+
name: logger
|
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
|
32
|
+
requirements:
|
|
33
|
+
- - ">="
|
|
34
|
+
- !ruby/object:Gem::Version
|
|
35
|
+
version: '0'
|
|
36
|
+
type: :runtime
|
|
37
|
+
prerelease: false
|
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
39
|
+
requirements:
|
|
40
|
+
- - ">="
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
version: '0'
|
|
16
43
|
- !ruby/object:Gem::Dependency
|
|
17
44
|
name: redis-namespace
|
|
18
45
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -27,20 +54,34 @@ dependencies:
|
|
|
27
54
|
- - "~>"
|
|
28
55
|
- !ruby/object:Gem::Version
|
|
29
56
|
version: '1.6'
|
|
57
|
+
- !ruby/object:Gem::Dependency
|
|
58
|
+
name: redis
|
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
|
60
|
+
requirements:
|
|
61
|
+
- - ">="
|
|
62
|
+
- !ruby/object:Gem::Version
|
|
63
|
+
version: '4.0'
|
|
64
|
+
type: :runtime
|
|
65
|
+
prerelease: false
|
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
67
|
+
requirements:
|
|
68
|
+
- - ">="
|
|
69
|
+
- !ruby/object:Gem::Version
|
|
70
|
+
version: '4.0'
|
|
30
71
|
- !ruby/object:Gem::Dependency
|
|
31
72
|
name: sinatra
|
|
32
73
|
requirement: !ruby/object:Gem::Requirement
|
|
33
74
|
requirements:
|
|
34
75
|
- - ">="
|
|
35
76
|
- !ruby/object:Gem::Version
|
|
36
|
-
version: 0
|
|
77
|
+
version: '2.0'
|
|
37
78
|
type: :runtime
|
|
38
79
|
prerelease: false
|
|
39
80
|
version_requirements: !ruby/object:Gem::Requirement
|
|
40
81
|
requirements:
|
|
41
82
|
- - ">="
|
|
42
83
|
- !ruby/object:Gem::Version
|
|
43
|
-
version: 0
|
|
84
|
+
version: '2.0'
|
|
44
85
|
- !ruby/object:Gem::Dependency
|
|
45
86
|
name: multi_json
|
|
46
87
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -70,7 +111,7 @@ dependencies:
|
|
|
70
111
|
- !ruby/object:Gem::Version
|
|
71
112
|
version: '1'
|
|
72
113
|
- !ruby/object:Gem::Dependency
|
|
73
|
-
name:
|
|
114
|
+
name: puma
|
|
74
115
|
requirement: !ruby/object:Gem::Requirement
|
|
75
116
|
requirements:
|
|
76
117
|
- - ">="
|
|
@@ -127,6 +168,7 @@ files:
|
|
|
127
168
|
- Rakefile
|
|
128
169
|
- bin/resque
|
|
129
170
|
- bin/resque-web
|
|
171
|
+
- lib/active_job/queue_adapters/resque_adapter.rb
|
|
130
172
|
- lib/resque.rb
|
|
131
173
|
- lib/resque/data_store.rb
|
|
132
174
|
- lib/resque/errors.rb
|
|
@@ -186,7 +228,6 @@ licenses:
|
|
|
186
228
|
metadata:
|
|
187
229
|
changelog_uri: https://github.com/resque/resque/blob/master/HISTORY.md
|
|
188
230
|
rubygems_mfa_required: 'true'
|
|
189
|
-
post_install_message:
|
|
190
231
|
rdoc_options:
|
|
191
232
|
- "--charset=UTF-8"
|
|
192
233
|
require_paths:
|
|
@@ -195,15 +236,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
195
236
|
requirements:
|
|
196
237
|
- - ">="
|
|
197
238
|
- !ruby/object:Gem::Version
|
|
198
|
-
version:
|
|
239
|
+
version: 3.0.0
|
|
199
240
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
200
241
|
requirements:
|
|
201
242
|
- - ">="
|
|
202
243
|
- !ruby/object:Gem::Version
|
|
203
244
|
version: '0'
|
|
204
245
|
requirements: []
|
|
205
|
-
rubygems_version:
|
|
206
|
-
signing_key:
|
|
246
|
+
rubygems_version: 4.0.6
|
|
207
247
|
specification_version: 4
|
|
208
248
|
summary: Resque is a Redis-backed queueing system.
|
|
209
249
|
test_files: []
|