sidekiq 2.5.1 → 2.5.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sidekiq might be problematic. Click here for more details.

Files changed (39) hide show
  1. data/.rvmrc +0 -1
  2. data/Changes.md +10 -0
  3. data/Gemfile +2 -5
  4. data/examples/sinkiq.rb +2 -2
  5. data/lib/sidekiq/cli.rb +7 -2
  6. data/lib/sidekiq/manager.rb +4 -4
  7. data/lib/sidekiq/middleware/server/retry_jobs.rb +1 -1
  8. data/lib/sidekiq/testing.rb +3 -2
  9. data/lib/sidekiq/version.rb +1 -1
  10. data/lib/sidekiq/web.rb +2 -59
  11. data/sidekiq.gemspec +0 -4
  12. data/test/helper.rb +4 -1
  13. data/test/test_middleware.rb +0 -1
  14. data/test/test_retry.rb +1 -1
  15. data/test/test_stats.rb +6 -8
  16. data/test/test_testing.rb +31 -0
  17. data/web/assets/javascripts/application.js +6 -11
  18. data/web/assets/javascripts/vendor/bootstrap.js +6 -2026
  19. data/web/assets/javascripts/vendor/jquery.js +2 -9265
  20. data/web/assets/stylesheets/application.css +544 -4
  21. data/web/assets/stylesheets/bootstrap.css +20 -0
  22. data/web/views/_workers.slim +1 -1
  23. data/web/views/layout.slim +6 -3
  24. metadata +3 -81
  25. data/web/assets/stylesheets/layout.css +0 -30
  26. data/web/assets/stylesheets/partials/_base.scss +0 -116
  27. data/web/assets/stylesheets/partials/_colors.scss +0 -46
  28. data/web/assets/stylesheets/partials/_fonts.scss +0 -3
  29. data/web/assets/stylesheets/partials/_h5bp.scss +0 -293
  30. data/web/assets/stylesheets/partials/_layout.scss +0 -197
  31. data/web/assets/stylesheets/partials/_navbar.scss +0 -100
  32. data/web/assets/stylesheets/partials/_normalize.scss +0 -504
  33. data/web/assets/stylesheets/partials/_prettify.css +0 -30
  34. data/web/assets/stylesheets/partials/_variables.scss +0 -28
  35. data/web/assets/stylesheets/public.scss +0 -74
  36. data/web/assets/stylesheets/style.scss +0 -69
  37. data/web/assets/stylesheets/vendor/bootstrap-responsive.css +0 -1040
  38. data/web/assets/stylesheets/vendor/bootstrap.css +0 -5624
  39. data/web/assets/stylesheets/vendors.scss +0 -2
data/.rvmrc CHANGED
@@ -1,4 +1,3 @@
1
1
  export RUBYOPT="-Ilib:test"
2
- export JRUBY_OPTS="--1.9"
3
2
  rvm use 1.9.3@sidekiq --create
4
3
  #rvm use jruby@sidekiq --create
data/Changes.md CHANGED
@@ -1,3 +1,13 @@
1
+ 2.5.2
2
+ -----------
3
+
4
+ - Remove asset pipeline from Web UI for much faster, simpler runtime. [#499, #490, #481]
5
+ - Add -g option so the procline better identifies a Sidekiq process, defaults to File.basename(Rails.root). [#486]
6
+
7
+ sidekiq 2.5.1 myapp [0 of 25 busy]
8
+
9
+ - Add splay to retry time so groups of failed jobs don't fire all at once. [#483]
10
+
1
11
  2.5.1
2
12
  -----------
3
13
 
data/Gemfile CHANGED
@@ -3,16 +3,13 @@ gemspec
3
3
 
4
4
  gem 'celluloid', "~> 0.12.0"
5
5
  gem 'slim'
6
- gem 'sass'
7
- gem 'rails', '3.2.8'
8
- gem 'sqlite3'
6
+ gem 'sqlite3', :platform => :mri
9
7
 
10
8
  group :test do
11
9
  gem 'simplecov', :require => false
12
10
  end
13
11
 
14
12
  group :development do
15
- gem 'sprockets-sass'
16
- gem 'compass'
13
+ gem 'pry', :platform => :mri
17
14
  gem 'shotgun'
18
15
  end
data/examples/sinkiq.rb CHANGED
@@ -19,8 +19,8 @@ class SinatraWorker
19
19
  end
20
20
 
21
21
  get '/' do
22
- @failed = Sidekiq::Stats.failed
23
- @processed = Sidekiq::Stats.processed
22
+ @failed = Sidekiq.info[:failed]
23
+ @processed = Sidekiq.info[:processed]
24
24
  @messages = $redis.lrange('sinkiq-example-messages', 0, -1)
25
25
  erb :index
26
26
  end
data/lib/sidekiq/cli.rb CHANGED
@@ -126,6 +126,7 @@ module Sidekiq
126
126
  require 'sidekiq/rails'
127
127
  require File.expand_path("#{options[:require]}/config/environment.rb")
128
128
  ::Rails.application.eager_load!
129
+ options[:tag] ||= File.basename(::Rails.root)
129
130
  else
130
131
  require options[:require]
131
132
  end
@@ -164,7 +165,11 @@ module Sidekiq
164
165
  end
165
166
 
166
167
  o.on '-t', '--timeout NUM', "Shutdown timeout" do |arg|
167
- opts[:timeout] = arg.to_i
168
+ opts[:timeout] = Integer(arg)
169
+ end
170
+
171
+ o.on '-g', '--tag TAG', "Process tag for procline" do |arg|
172
+ opts[:tag] = arg
168
173
  end
169
174
 
170
175
  o.on '-r', '--require [PATH|DIR]', "Location of Rails application with workers or file to require" do |arg|
@@ -172,7 +177,7 @@ module Sidekiq
172
177
  end
173
178
 
174
179
  o.on '-c', '--concurrency INT', "processor threads to use" do |arg|
175
- opts[:concurrency] = arg.to_i
180
+ opts[:concurrency] = Integer(arg)
176
181
  end
177
182
 
178
183
  o.on '-P', '--pidfile PATH', "path to pidfile" do |arg|
@@ -27,7 +27,7 @@ module Sidekiq
27
27
  @busy = []
28
28
  @fetcher = Fetcher.new(current_actor, options[:queues], !!options[:strict])
29
29
  @ready = @count.times.map { Processor.new_link(current_actor) }
30
- procline
30
+ procline(options[:tag] ? "#{options[:tag]} " : '')
31
31
  end
32
32
 
33
33
  def stop(options={})
@@ -153,9 +153,9 @@ module Sidekiq
153
153
  @done
154
154
  end
155
155
 
156
- def procline
157
- $0 = "sidekiq #{Sidekiq::VERSION} [#{@busy.size} of #{@count} busy]#{stopped? ? ' stopping' : ''}"
158
- after(5) { procline }
156
+ def procline(tag)
157
+ $0 = "sidekiq #{Sidekiq::VERSION} #{tag}[#{@busy.size} of #{@count} busy]#{stopped? ? ' stopping' : ''}"
158
+ after(5) { procline(tag) }
159
159
  end
160
160
  end
161
161
  end
@@ -43,7 +43,7 @@ module Sidekiq
43
43
 
44
44
  # delayed_job uses the same basic formula
45
45
  DEFAULT_MAX_RETRY_ATTEMPTS = 25
46
- DELAY = proc { |count| (count ** 4) + 15 }
46
+ DELAY = proc { |count| (count ** 4) + 15 + (rand(30)*(count+1)) }
47
47
 
48
48
  def call(worker, msg, queue)
49
49
  yield
@@ -93,8 +93,9 @@ module Sidekiq
93
93
 
94
94
  # Drain all queued jobs across all workers
95
95
  def drain_all
96
- jobs.keys.each(&:drain)
97
- clear_all
96
+ until jobs.values.all?(&:empty?) do
97
+ jobs.keys.each(&:drain)
98
+ end
98
99
  end
99
100
  end
100
101
  end
@@ -1,3 +1,3 @@
1
1
  module Sidekiq
2
- VERSION = "2.5.1"
2
+ VERSION = "2.5.2"
3
3
  end
data/lib/sidekiq/web.rb CHANGED
@@ -1,75 +1,17 @@
1
1
  require 'sinatra/base'
2
2
  require 'slim'
3
- require 'sprockets'
4
- require 'sprockets-sass'
5
- require 'sass'
6
- require 'compass'
7
3
  require 'sidekiq/paginator'
8
4
 
9
5
  module Sidekiq
10
- class SprocketsMiddleware
11
- def initialize(app, options={})
12
- @app = app
13
- @root = options[:root]
14
- path = options[:path] || 'assets'
15
- @matcher = /^\/#{path}\/*/
16
- @environment = ::Sprockets::Environment.new(@root)
17
- @environment.append_path 'assets/javascripts'
18
- @environment.append_path 'assets/javascripts/vendor'
19
- @environment.append_path 'assets/stylesheets'
20
- @environment.append_path 'assets/stylesheets/vendor'
21
- @environment.append_path 'assets/images'
22
-
23
- Compass.configuration do |config|
24
-
25
- config.project_path = "#{@root}/assets"
26
-
27
- config.images_dir = 'images'
28
- config.sass_dir = 'stylesheets'
29
- config.css_dir = 'stylesheets'
30
- config.javascripts_dir = 'javascripts'
31
- config.fonts_dir = 'stylesheets/fonts'
32
-
33
- config.http_images_path = '/assets'
34
- config.http_generated_images_path = '/assets'
35
- config.http_javascripts_path = '/assets'
36
- config.http_stylesheets_path = '/assets'
37
-
38
- # You can select your preferred output style here (can be overridden via the command line):
39
- output_style = :compressed
40
-
41
- # To enable relative paths to assets via compass helper functions. Uncomment:
42
- relative_assets = true
43
-
44
- # To disable debugging comments that display the original location of your selectors. Uncomment:
45
- line_comments = false
46
- end
47
-
48
-
49
- end
50
-
51
- def call(env)
52
- # Solve the problem of people requesting /sidekiq when they need to request /sidekiq/ so
53
- # that relative links in templates resolve correctly.
54
- return [301, { 'Location' => "#{env['SCRIPT_NAME']}/", 'Content-Type' => 'text/html' }, ['redirecting']] if env['SCRIPT_NAME'] == env['REQUEST_PATH']
55
-
56
- return @app.call(env) unless @matcher =~ env["PATH_INFO"]
57
- env['PATH_INFO'].sub!(@matcher,'')
58
- @environment.call(env)
59
- end
60
- end
61
-
62
6
  class Web < Sinatra::Base
63
7
  include Sidekiq::Paginator
64
8
 
65
9
  dir = File.expand_path(File.dirname(__FILE__) + "/../../web")
10
+ set :public_folder, "#{dir}/assets"
66
11
  set :views, "#{dir}/views"
67
12
  set :root, "#{dir}/public"
68
13
  set :slim, :pretty => true
69
14
 
70
- use SprocketsMiddleware, :root => dir
71
-
72
-
73
15
  helpers do
74
16
 
75
17
  def reset_worker_list
@@ -295,3 +237,4 @@ module Sidekiq
295
237
  end
296
238
 
297
239
  end
240
+
data/sidekiq.gemspec CHANGED
@@ -19,14 +19,10 @@ Gem::Specification.new do |gem|
19
19
  gem.add_dependency 'connection_pool', '~> 0.9.2'
20
20
  gem.add_dependency 'celluloid', '~> 0.12.0'
21
21
  gem.add_dependency 'multi_json', '~> 1'
22
- gem.add_dependency 'sprockets-sass'
23
- gem.add_dependency 'sass'
24
- gem.add_dependency 'compass'
25
22
  gem.add_development_dependency 'minitest', '~> 3'
26
23
  gem.add_development_dependency 'sinatra'
27
24
  gem.add_development_dependency 'slim'
28
25
  gem.add_development_dependency 'rake'
29
26
  gem.add_development_dependency 'actionmailer', '~> 3'
30
27
  gem.add_development_dependency 'activerecord', '~> 3'
31
- gem.add_development_dependency 'pry'
32
28
  end
data/test/helper.rb CHANGED
@@ -4,7 +4,10 @@ if ENV.has_key?("SIMPLECOV")
4
4
  SimpleCov.start
5
5
  end
6
6
 
7
- require 'pry'
7
+ begin
8
+ require 'pry'
9
+ rescue LoadError
10
+ end
8
11
 
9
12
  require 'minitest/unit'
10
13
  require 'minitest/pride'
@@ -43,7 +43,6 @@ class TestMiddleware < MiniTest::Unit::TestCase
43
43
  end
44
44
 
45
45
  it 'executes middleware in the proper order' do
46
- recorder = []
47
46
  msg = Sidekiq.dump_json({ 'class' => CustomWorker.to_s, 'args' => [$recorder] })
48
47
 
49
48
  Sidekiq.server_middleware do |chain|
data/test/test_retry.rb CHANGED
@@ -35,7 +35,7 @@ class TestRetry < MiniTest::Unit::TestCase
35
35
  end
36
36
  end
37
37
  assert msg["error_backtrace"]
38
- assert_equal c, msg["error_backtrace"]
38
+ assert_equal c[0], msg["error_backtrace"][0]
39
39
  end
40
40
 
41
41
  it 'saves partial backtraces' do
data/test/test_stats.rb CHANGED
@@ -55,7 +55,6 @@ class TestStats < MiniTest::Unit::TestCase
55
55
 
56
56
  processor = Sidekiq::Processor.new(boss)
57
57
 
58
- pstr = processor.to_s
59
58
  assert_raises RuntimeError do
60
59
  processor.process(msg, 'xyzzy')
61
60
  end
@@ -71,24 +70,23 @@ class TestStats < MiniTest::Unit::TestCase
71
70
  conn.rpush 'queue:foo', '{}'
72
71
  conn.sadd 'queues', 'foo'
73
72
 
74
- conn.rpush 'queue:bar', '{}'
75
- conn.rpush 'queue:bar', '{}'
73
+ 3.times { conn.rpush 'queue:bar', '{}' }
76
74
  conn.sadd 'queues', 'bar'
77
75
 
78
- conn.rpush 'queue:baz', '{}'
76
+ 2.times { conn.rpush 'queue:baz', '{}' }
79
77
  conn.sadd 'queues', 'baz'
80
78
  end
81
79
  end
82
80
 
83
81
  describe "queues_with_sizes" do
84
82
  it "returns queue names and corresponding job counts" do
85
- assert_equal [["foo", 1], ["baz", 1], ["bar", 2]], Sidekiq.info[:queues_with_sizes]
83
+ assert_equal [["foo", 1], ["baz", 2], ["bar", 3]], Sidekiq.info[:queues_with_sizes]
86
84
  end
87
85
  end
88
86
 
89
87
  describe "backlog" do
90
88
  it "returns count of all jobs yet to be processed" do
91
- assert_equal 4, Sidekiq.info[:backlog]
89
+ assert_equal 6, Sidekiq.info[:backlog]
92
90
  end
93
91
  end
94
92
 
@@ -97,8 +95,8 @@ class TestStats < MiniTest::Unit::TestCase
97
95
  assert_equal 0, Sidekiq.size("foox")
98
96
  assert_equal 1, Sidekiq.size(:foo)
99
97
  assert_equal 1, Sidekiq.size("foo")
100
- assert_equal 3, Sidekiq.size("foo", "bar")
101
- assert_equal 4, Sidekiq.size
98
+ assert_equal 4, Sidekiq.size("foo", "bar")
99
+ assert_equal 6, Sidekiq.size
102
100
  end
103
101
  end
104
102
  end
data/test/test_testing.rb CHANGED
@@ -129,6 +129,15 @@ class TestTesting < MiniTest::Unit::TestCase
129
129
  end
130
130
  end
131
131
 
132
+ class ThirdWorker
133
+ include Sidekiq::Worker
134
+ class_attribute :count
135
+ def perform
136
+ FirstWorker.perform_async
137
+ SecondWorker.perform_async
138
+ end
139
+ end
140
+
132
141
  it 'clears jobs across all workers' do
133
142
  Sidekiq::Worker.jobs.clear
134
143
  FirstWorker.count = 0
@@ -177,5 +186,27 @@ class TestTesting < MiniTest::Unit::TestCase
177
186
  assert_equal 1, FirstWorker.count
178
187
  assert_equal 1, SecondWorker.count
179
188
  end
189
+
190
+ it 'drains jobs across all workers even when workers create new jobs' do
191
+ Sidekiq::Worker.jobs.clear
192
+ FirstWorker.count = 0
193
+ SecondWorker.count = 0
194
+
195
+ assert_equal 0, ThirdWorker.jobs.size
196
+
197
+ assert_equal 0, FirstWorker.count
198
+ assert_equal 0, SecondWorker.count
199
+
200
+ ThirdWorker.perform_async
201
+
202
+ assert_equal 1, ThirdWorker.jobs.size
203
+
204
+ Sidekiq::Worker.drain_all
205
+
206
+ assert_equal 0, ThirdWorker.jobs.size
207
+
208
+ assert_equal 1, FirstWorker.count
209
+ assert_equal 1, SecondWorker.count
210
+ end
180
211
  end
181
212
  end
@@ -1,8 +1,3 @@
1
- //= require vendor/jquery
2
- //= require vendor/jquery.timeago
3
- //= require bootstrap
4
- //= require_tree .
5
-
6
1
  $(function() {
7
2
  $.timeago.settings.allowFuture = true;
8
3
  $.timeago.settings.refreshMillis = 0;
@@ -25,12 +20,12 @@ $(function() {
25
20
 
26
21
  $('a[name=poll]').data('polling', false);
27
22
 
28
- pollStatus = $('.poll-status')
23
+ var pollStatus = $('.poll-status');
29
24
 
30
- pollStatusText = pollStatus.find('.text')
31
- pollStatusBadge = pollStatus.find('.badge')
25
+ var pollStatusText = pollStatus.find('.text');
26
+ var pollStatusBadge = pollStatus.find('.badge');
32
27
  pollStatusBadge.hide();
33
- pollStatusMarkup = pollStatus.html();
28
+ var pollStatusMarkup = pollStatus.html();
34
29
 
35
30
  $('a[name=poll]').on('click', function(e) {
36
31
  e.preventDefault();
@@ -75,9 +70,9 @@ $(function() {
75
70
  $('time').timeago();
76
71
  });
77
72
  var currentTime = new Date();
78
- $('.poll-status .text').text('Last polled: ')
73
+ $('.poll-status .text').text('Last polled: ');
79
74
  $('.poll-status .time').show().text(currentTime.getHours() + ':' + pad(currentTime.getMinutes()) + ':' + pad(currentTime.getSeconds()));
80
- }
75
+ };
81
76
  });
82
77
 
83
78
  $(function() {