shoryuken 3.0.4 → 3.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e1367b27e316c258563ef328b78bc64947c849d8
4
- data.tar.gz: 285db9748d737bfe07a6904db381d3c11883cd05
3
+ metadata.gz: a7a48b27440a94923275b030e8785feb20e3b628
4
+ data.tar.gz: 629c1e8369fef39bf795860d3cdd565f2ed6c886
5
5
  SHA512:
6
- metadata.gz: 7f85154f339098c0b04a01673548b0c688217290772131dc28a1ed0c378b0cb671576f5a195143d915a8ab70ed836b089bd12ff6c4d6aa78d81bf858729323a6
7
- data.tar.gz: 9b5180a9baf239178c11afcc7f55d31392162deeb95aa7f49836a64e94fcc114b145ba82414b83ad22d278612d3cca53436bb804d41d98ccfbe9f1eea4f678cc
6
+ metadata.gz: 77e1c8fb04eea615ae5ba684978c5278631a3dab89119d9519ee3e0514da3ca3cdeb12feb672beb2024f5f708d986953b1b6a0191ea4c3e75e3e507809c710e3
7
+ data.tar.gz: dbff1f35986729de23d4934dccab52546642297334f1117c925c89fdbf8735575ae2dd0bc990e547018a60921a19f59cd04968093d73072609156ac8ff4541f5
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## [v3.0.5] - 2017-04-09
2
+ - Pause endless dispatcher to avoid CPU overload
3
+ - [#354](https://github.com/phstc/shoryuken/pull/354)
4
+
5
+ - Auto log processor errors
6
+ - [#355](https://github.com/phstc/shoryuken/pull/355)
7
+
8
+ - Add a delay as a CLI param
9
+ - [#350](https://github.com/phstc/shoryuken/pull/350)
10
+
11
+ - Add `sqs purge` command. See https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_PurgeQueue.html
12
+ - [#344](https://github.com/phstc/shoryuken/pull/344)
1
13
  ## [v3.0.4] - 2017-03-24
2
14
  - Add `sqs purge` command. See https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_PurgeQueue.html
3
15
  - [#344](https://github.com/phstc/shoryuken/pull/344)
data/bin/shoryuken CHANGED
@@ -21,14 +21,22 @@ module Shoryuken
21
21
  method_option :daemon, aliases: '-d', type: :boolean, desc: 'Daemonize process'
22
22
  method_option :queues, aliases: '-q', type: :array, desc: 'Queues to process with optional weights'
23
23
  method_option :require, aliases: '-r', type: :string, desc: 'Dir or path of the workers'
24
- method_option :config_file, aliases: '-C', type: :string, desc: 'Path to config file'
24
+ method_option :config, aliases: '-C', type: :string, desc: 'Path to config file'
25
+ method_option :config_file, type: :string, desc: 'Path to config file (backwards compatibility)'
25
26
  method_option :rails, aliases: '-R', type: :boolean, desc: 'Load Rails'
26
27
  method_option :logfile, aliases: '-L', type: :string, desc: 'Path to logfile'
27
28
  method_option :pidfile, aliases: '-P', type: :string, desc: 'Path to pidfile'
28
29
  method_option :verbose, aliases: '-v', type: :boolean, desc: 'Print more verbose output'
30
+ method_option :delay, aliases: '-D', type: :boolean, desc: 'Number of seconds to pause fetching from an empty queue'
29
31
  def start
30
32
  opts = options.to_h.symbolize_keys
31
33
 
34
+ if opts[:config_file]
35
+ say "[DEPRECATED] Please use --config instead of --config-file", :yellow
36
+ end
37
+
38
+ opts[:config_file] = opts.delete(:config) if opts[:config]
39
+
32
40
  # Keep compatibility with old CLI queue format
33
41
  opts[:queues] = options[:queues].map { |q| q.split(',') } if options[:queues]
34
42
 
@@ -3,6 +3,8 @@ module Shoryuken
3
3
  include Util
4
4
 
5
5
  BATCH_LIMIT = 10
6
+ # See https://github.com/phstc/shoryuken/issues/348#issuecomment-292847028
7
+ MIN_DISPATCH_INTERVAL = 0.1
6
8
 
7
9
  def initialize(fetcher, polling_strategy)
8
10
  @count = Shoryuken.options.fetch(:concurrency, 25)
@@ -47,6 +49,11 @@ module Shoryuken
47
49
  end
48
50
  end
49
51
 
52
+ def processor_failed(ex)
53
+ logger.error ex
54
+ logger.error ex.backtrace.join("\n") unless ex.backtrace.nil?
55
+ end
56
+
50
57
  def processor_done(queue)
51
58
  logger.debug { "Process done for '#{queue}'" }
52
59
  end
@@ -61,8 +68,10 @@ module Shoryuken
61
68
  return if @done.true?
62
69
 
63
70
  begin
64
- return if ready.zero?
65
- return unless (queue = @polling_strategy.next_queue)
71
+ if ready.zero? || (queue = @polling_strategy.next_queue).nil?
72
+ sleep MIN_DISPATCH_INTERVAL
73
+ return
74
+ end
66
75
 
67
76
  logger.debug { "Ready: #{ready}, Busy: #{busy}, Active Queues: #{@polling_strategy.active_queues}" }
68
77
 
@@ -13,6 +13,9 @@ module Shoryuken
13
13
  worker.class.server_middleware.invoke(worker, queue, sqs_msg, body) do
14
14
  worker.perform(sqs_msg, body)
15
15
  end
16
+ rescue Exception => ex
17
+ @manager.processor_failed(ex)
18
+ raise
16
19
  ensure
17
20
  @manager.processor_done(queue)
18
21
  end
@@ -1,3 +1,3 @@
1
1
  module Shoryuken
2
- VERSION = '3.0.4'.freeze
2
+ VERSION = '3.0.5'.freeze
3
3
  end
@@ -99,6 +99,7 @@ RSpec.describe Shoryuken::Processor do
99
99
  end
100
100
 
101
101
  it 'logs the error' do
102
+ expect(manager).to receive(:processor_failed)
102
103
  expect(subject.logger).to receive(:error) do |&block|
103
104
  expect(block.call).
104
105
  to include("unexpected token at 'invalid json'\nbody_parser: json\nsqs_msg.body: invalid json")
@@ -108,6 +109,7 @@ RSpec.describe Shoryuken::Processor do
108
109
  end
109
110
 
110
111
  it 're raises the error' do
112
+ expect(manager).to receive(:processor_failed)
111
113
  expect { subject.process(queue, sqs_msg) }.
112
114
  to raise_error(JSON::ParserError, /unexpected token at 'invalid json'/)
113
115
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shoryuken
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.4
4
+ version: 3.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pablo Cantero
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-24 00:00:00.000000000 Z
11
+ date: 2017-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler