sidekiq 4.1.4 → 4.2.10

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 (134) hide show
  1. checksums.yaml +4 -4
  2. data/.github/issue_template.md +6 -1
  3. data/.travis.yml +9 -9
  4. data/Changes.md +100 -0
  5. data/Ent-Changes.md +51 -1
  6. data/Gemfile +6 -6
  7. data/Pro-Changes.md +69 -0
  8. data/README.md +4 -3
  9. data/Rakefile +5 -2
  10. data/bin/sidekiqload +11 -24
  11. data/lib/generators/sidekiq/templates/worker_test.rb.erb +1 -1
  12. data/lib/sidekiq/api.rb +21 -13
  13. data/lib/sidekiq/cli.rb +19 -5
  14. data/lib/sidekiq/core_ext.rb +13 -0
  15. data/lib/sidekiq/launcher.rb +36 -23
  16. data/lib/sidekiq/manager.rb +3 -2
  17. data/lib/sidekiq/middleware/server/logging.rb +8 -17
  18. data/lib/sidekiq/middleware/server/retry_jobs.rb +1 -1
  19. data/lib/sidekiq/processor.rb +31 -16
  20. data/lib/sidekiq/rails.rb +84 -0
  21. data/lib/sidekiq/redis_connection.rb +8 -1
  22. data/lib/sidekiq/scheduled.rb +1 -0
  23. data/lib/sidekiq/testing.rb +10 -2
  24. data/lib/sidekiq/util.rb +2 -1
  25. data/lib/sidekiq/version.rb +1 -1
  26. data/lib/sidekiq/web/action.rb +93 -0
  27. data/lib/sidekiq/web/application.rb +336 -0
  28. data/lib/sidekiq/{web_helpers.rb → web/helpers.rb} +39 -16
  29. data/lib/sidekiq/web/router.rb +100 -0
  30. data/lib/sidekiq/web.rb +119 -184
  31. data/lib/sidekiq/worker.rb +3 -3
  32. data/lib/sidekiq.rb +7 -7
  33. data/sidekiq.gemspec +11 -5
  34. data/web/assets/images/{status-sd8051fd480.png → status.png} +0 -0
  35. data/web/assets/javascripts/application.js +24 -20
  36. data/web/assets/javascripts/dashboard.js +1 -1
  37. data/web/assets/stylesheets/application.css +26 -1
  38. data/web/assets/stylesheets/bootstrap.css +4 -8
  39. data/web/locales/de.yml +1 -1
  40. data/web/locales/fa.yml +79 -0
  41. data/web/views/_footer.erb +1 -1
  42. data/web/views/_job_info.erb +1 -1
  43. data/web/views/busy.erb +2 -2
  44. data/web/views/dashboard.erb +4 -4
  45. data/web/views/dead.erb +1 -1
  46. data/web/views/layout.erb +3 -4
  47. data/web/views/morgue.erb +14 -10
  48. data/web/views/queue.erb +6 -6
  49. data/web/views/queues.erb +3 -3
  50. data/web/views/retries.erb +12 -10
  51. data/web/views/retry.erb +2 -2
  52. data/web/views/scheduled.erb +2 -2
  53. data/web/views/scheduled_job_info.erb +1 -1
  54. metadata +86 -129
  55. data/test/config.yml +0 -9
  56. data/test/env_based_config.yml +0 -11
  57. data/test/fake_env.rb +0 -1
  58. data/test/fixtures/en.yml +0 -2
  59. data/test/helper.rb +0 -75
  60. data/test/test_actors.rb +0 -138
  61. data/test/test_api.rb +0 -528
  62. data/test/test_cli.rb +0 -406
  63. data/test/test_client.rb +0 -266
  64. data/test/test_exception_handler.rb +0 -56
  65. data/test/test_extensions.rb +0 -127
  66. data/test/test_fetch.rb +0 -50
  67. data/test/test_launcher.rb +0 -85
  68. data/test/test_logging.rb +0 -35
  69. data/test/test_manager.rb +0 -50
  70. data/test/test_middleware.rb +0 -158
  71. data/test/test_processor.rb +0 -201
  72. data/test/test_rails.rb +0 -22
  73. data/test/test_redis_connection.rb +0 -132
  74. data/test/test_retry.rb +0 -326
  75. data/test/test_retry_exhausted.rb +0 -149
  76. data/test/test_scheduled.rb +0 -115
  77. data/test/test_scheduling.rb +0 -50
  78. data/test/test_sidekiq.rb +0 -107
  79. data/test/test_testing.rb +0 -143
  80. data/test/test_testing_fake.rb +0 -357
  81. data/test/test_testing_inline.rb +0 -94
  82. data/test/test_util.rb +0 -13
  83. data/test/test_web.rb +0 -614
  84. data/test/test_web_helpers.rb +0 -54
  85. data/web/assets/images/bootstrap/glyphicons-halflings-white.png +0 -0
  86. data/web/assets/images/bootstrap/glyphicons-halflings.png +0 -0
  87. data/web/assets/images/status/active.png +0 -0
  88. data/web/assets/images/status/idle.png +0 -0
  89. data/web/assets/javascripts/locales/README.md +0 -27
  90. data/web/assets/javascripts/locales/jquery.timeago.ar.js +0 -96
  91. data/web/assets/javascripts/locales/jquery.timeago.bg.js +0 -18
  92. data/web/assets/javascripts/locales/jquery.timeago.bs.js +0 -49
  93. data/web/assets/javascripts/locales/jquery.timeago.ca.js +0 -18
  94. data/web/assets/javascripts/locales/jquery.timeago.cs.js +0 -18
  95. data/web/assets/javascripts/locales/jquery.timeago.cy.js +0 -20
  96. data/web/assets/javascripts/locales/jquery.timeago.da.js +0 -18
  97. data/web/assets/javascripts/locales/jquery.timeago.de.js +0 -18
  98. data/web/assets/javascripts/locales/jquery.timeago.el.js +0 -18
  99. data/web/assets/javascripts/locales/jquery.timeago.en-short.js +0 -20
  100. data/web/assets/javascripts/locales/jquery.timeago.en.js +0 -20
  101. data/web/assets/javascripts/locales/jquery.timeago.es.js +0 -18
  102. data/web/assets/javascripts/locales/jquery.timeago.et.js +0 -18
  103. data/web/assets/javascripts/locales/jquery.timeago.fa.js +0 -22
  104. data/web/assets/javascripts/locales/jquery.timeago.fi.js +0 -28
  105. data/web/assets/javascripts/locales/jquery.timeago.fr-short.js +0 -16
  106. data/web/assets/javascripts/locales/jquery.timeago.fr.js +0 -17
  107. data/web/assets/javascripts/locales/jquery.timeago.he.js +0 -18
  108. data/web/assets/javascripts/locales/jquery.timeago.hr.js +0 -49
  109. data/web/assets/javascripts/locales/jquery.timeago.hu.js +0 -18
  110. data/web/assets/javascripts/locales/jquery.timeago.hy.js +0 -18
  111. data/web/assets/javascripts/locales/jquery.timeago.id.js +0 -18
  112. data/web/assets/javascripts/locales/jquery.timeago.it.js +0 -16
  113. data/web/assets/javascripts/locales/jquery.timeago.ja.js +0 -19
  114. data/web/assets/javascripts/locales/jquery.timeago.ko.js +0 -17
  115. data/web/assets/javascripts/locales/jquery.timeago.lt.js +0 -20
  116. data/web/assets/javascripts/locales/jquery.timeago.mk.js +0 -20
  117. data/web/assets/javascripts/locales/jquery.timeago.nb.js +0 -18
  118. data/web/assets/javascripts/locales/jquery.timeago.nl.js +0 -20
  119. data/web/assets/javascripts/locales/jquery.timeago.pl.js +0 -31
  120. data/web/assets/javascripts/locales/jquery.timeago.pt-br.js +0 -16
  121. data/web/assets/javascripts/locales/jquery.timeago.pt.js +0 -16
  122. data/web/assets/javascripts/locales/jquery.timeago.ro.js +0 -18
  123. data/web/assets/javascripts/locales/jquery.timeago.rs.js +0 -49
  124. data/web/assets/javascripts/locales/jquery.timeago.ru.js +0 -34
  125. data/web/assets/javascripts/locales/jquery.timeago.sk.js +0 -18
  126. data/web/assets/javascripts/locales/jquery.timeago.sl.js +0 -44
  127. data/web/assets/javascripts/locales/jquery.timeago.sv.js +0 -18
  128. data/web/assets/javascripts/locales/jquery.timeago.th.js +0 -20
  129. data/web/assets/javascripts/locales/jquery.timeago.tr.js +0 -16
  130. data/web/assets/javascripts/locales/jquery.timeago.uk.js +0 -34
  131. data/web/assets/javascripts/locales/jquery.timeago.uz.js +0 -19
  132. data/web/assets/javascripts/locales/jquery.timeago.zh-cn.js +0 -20
  133. data/web/assets/javascripts/locales/jquery.timeago.zh-tw.js +0 -20
  134. data/web/views/_poll_js.erb +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c4e031cb26d8dcc6ab4f404563cd0a711577e586
4
- data.tar.gz: 0a05484ed39032f71dcd2db901afec38f4c9d023
3
+ metadata.gz: 595500a3810c25e8e04e86c644f966ff01cb035f
4
+ data.tar.gz: 3f92a9f61e61848bc2c0639469ce3588f3848fc0
5
5
  SHA512:
6
- metadata.gz: c807c5e398088ee6b344cdce5fa57a77d51c7206a3cc11c4aeb8bc9af186eb82c292c215facb6ae54589ed5b1d95573b74a07622bc452b7ba970d0fb49c207df
7
- data.tar.gz: a56f9815bfc2954b12a9598b6678aee7771ee949d7e886dfc6ddaacbe05f5294e008deccf063c9c39ac430f18322cbdff4468a9ebd3530a9ef8ce780b064bf7e
6
+ metadata.gz: c4e97c3665d1e902f47cfb579fda437dc834ac4b584606f1ca3b8fd9225e8502cacf5fb687673b4735b359de6af179589759a34369f1c74e904b37f8fe70a4ee
7
+ data.tar.gz: a4e6d41067bf6b88c77577def0c1f9ecc3f5d46f0bdfb0821952c26867e91a71c64231aab09a25096d22c3272dea2dcc37547bc6096dd7622a192fa00e0a4e50
@@ -1,4 +1,9 @@
1
1
  Ruby version:
2
2
  Sidekiq / Pro / Enterprise version(s):
3
3
 
4
- If relevant, please include your initializer and any error message with the full backtrace.
4
+ Please include your initializer and any error message with the full backtrace.
5
+
6
+ Are you using an old version?
7
+ Have you checked the changelog to see if your issue has been fixed in a later version?
8
+
9
+ https://github.com/mperham/sidekiq/blob/master/Changes.md
data/.travis.yml CHANGED
@@ -6,13 +6,13 @@ services:
6
6
  before_install:
7
7
  - gem install bundler
8
8
  - gem update bundler
9
- rvm:
10
- - 2.0.0
11
- - 2.1.8
12
- - 2.2.4
13
- - 2.3.0
14
- - jruby-head
15
- - rbx-2
16
9
  matrix:
17
- allow_failures:
18
- - rvm: rbx-2
10
+ include:
11
+ - rvm: 2.2.4
12
+ env: "PERCY_ENABLE=0"
13
+ - rvm: 2.3.0
14
+ env: "PERCY_ENABLE=0"
15
+ - rvm: 2.4.0
16
+ env: "PERCY_ENABLE=1"
17
+ - rvm: jruby-9.1.6.0
18
+ env: "PERCY_ENABLE=0"
data/Changes.md CHANGED
@@ -1,5 +1,105 @@
1
1
  # Sidekiq Changes
2
2
 
3
+ HEAD
4
+ -----------
5
+
6
+ - Scheduled jobs can now be moved directly to the Dead queue via API [#3390]
7
+ - Fix edge case leading to job duplication when using Sidekiq Pro's
8
+ reliability feature [#3388]
9
+ - Fix error class name display on retry page [#3348]
10
+ - More robust latency calculation [#3340]
11
+
12
+ 4.2.9
13
+ -----------
14
+
15
+ - Rollback [#3303] which broke Heroku Redis users [#3311]
16
+ - Add support for TSTP signal, for Sidekiq 5.0 forward compatibility. [#3302]
17
+
18
+ 4.2.8
19
+ -----------
20
+
21
+ - Fix rare edge case with Redis driver that can create duplicate jobs [#3303]
22
+ - Fix Rails 5 loading issue [#3275]
23
+ - Restore missing tooltips to timestamps in Web UI [#3310]
24
+ - Work on **Sidekiq 5.0** is now active! [#3301]
25
+
26
+ 4.2.7
27
+ -----------
28
+
29
+ - Add new integration testing to verify code loading and job execution
30
+ in development and production modes with Rails 4 and 5 [#3241]
31
+ - Fix delayed extensions in development mode [#3227, DarthSim]
32
+ - Use Worker's `retry` default if job payload does not have a retry
33
+ attribute [#3234, mlarraz]
34
+
35
+ 4.2.6
36
+ -----------
37
+
38
+ - Run Rails Executor when in production [#3221, eugeneius]
39
+
40
+ 4.2.5
41
+ -----------
42
+
43
+ - Re-enable eager loading of all code when running non-development Rails 5. [#3203]
44
+ - Better root URL handling for zany web servers [#3207]
45
+
46
+ 4.2.4
47
+ -----------
48
+
49
+ - Log errors coming from the Rails 5 reloader. [#3212, eugeneius]
50
+ - Clone job data so middleware changes don't appear in Busy tab
51
+
52
+ 4.2.3
53
+ -----------
54
+
55
+ - Disable use of Rails 5's Reloader API in non-development modes, it has proven
56
+ to be unstable under load [#3154]
57
+ - Allow disabling of Sidekiq::Web's cookie session to handle the
58
+ case where the app provides a session already [#3180, inkstak]
59
+ ```ruby
60
+ Sidekiq::Web.set :sessions, false
61
+ ```
62
+ - Fix Web UI sharding support broken in 4.2.2. [#3169]
63
+ - Fix timestamps not updating during UI polling [#3193, shaneog]
64
+ - Relax rack-protection version to >= 1.5.0
65
+ - Provide consistent interface to exception handlers, changing the structure of the context hash. [#3161]
66
+
67
+ 4.2.2
68
+ -----------
69
+
70
+ - Fix ever-increasing cookie size with nginx [#3146, cconstantine]
71
+ - Fix so Web UI works without trailing slash [#3158, timdorr]
72
+
73
+ 4.2.1
74
+ -----------
75
+
76
+ - Ensure browser does not cache JSON/AJAX responses. [#3136]
77
+ - Support old Sinatra syntax for setting config [#3139]
78
+
79
+ 4.2.0
80
+ -----------
81
+
82
+ - Enable development-mode code reloading. **With Rails 5.0+, you don't need
83
+ to restart Sidekiq to pick up your Sidekiq::Worker changes anymore!** [#2457]
84
+ - **Remove Sinatra dependency**. Sidekiq's Web UI now uses Rack directly.
85
+ Thank you to Sidekiq's newest committer, **badosu**, for writing the code
86
+ and doing a lot of testing to ensure compatibility with many different
87
+ 3rd party plugins. If your Web UI works with 4.1.4 but fails with
88
+ 4.2.0, please open an issue. [#3075]
89
+ - Allow tuning of concurrency with the `RAILS_MAX_THREADS` env var. [#2985]
90
+ This is the same var used by Puma so you can tune all of your systems
91
+ the same way:
92
+ ```sh
93
+ web: RAILS_MAX_THREADS=5 bundle exec puma ...
94
+ worker: RAILS_MAX_THREADS=10 bundle exec sidekiq ...
95
+ ```
96
+ Using `-c` or `config/sidekiq.yml` overrides this setting. I recommend
97
+ adjusting your `config/database.yml` to use it too so connections are
98
+ auto-scaled:
99
+ ```yaml
100
+ pool: <%= ENV['RAILS_MAX_THREADS'] || 5 %>
101
+ ```
102
+
3
103
  4.1.4
4
104
  -----------
5
105
 
data/Ent-Changes.md CHANGED
@@ -3,7 +3,57 @@ Sidekiq Enterprise Changelog
3
3
 
4
4
  Please see [http://sidekiq.org/](http://sidekiq.org/) for more details and how to buy.
5
5
 
6
- HEAD
6
+ 1.5.2
7
+ -------------
8
+
9
+ - Fix encrypted arguments double-encrypted by retry or rate limiting [#3368]
10
+ - Fix leak in concurrent rate limiter, run this in Rails console to clean up existing data [#3323]
11
+ ```ruby
12
+ expiry = 1.month.to_i; Sidekiq::Limiter.redis { |c| c.scan_each(match: "lmtr-cfree-*") { |key| c.expire(key, expiry) } }
13
+ ```
14
+
15
+ 1.5.1
16
+ -------------
17
+
18
+ - Fix issue with census startup when not using Bundler configuration for
19
+ source credentials.
20
+
21
+ 1.5.0
22
+ -------------
23
+
24
+ - Add new web authorization API [#3251]
25
+ - Update all sidekiqswarm env vars to use SIDEKIQ\_ prefix [#3218]
26
+ - Add census reporting, the leader will ping contribsys nightly with aggregate usage metrics
27
+
28
+ 1.4.0
29
+ -------------
30
+
31
+ - No functional changes, require latest Sidekiq and Sidekiq Pro versions
32
+
33
+ 1.3.2
34
+ -------------
35
+
36
+ - Upgrade encryption to use OpenSSL's more secure GCM mode. [#3060]
37
+
38
+ 1.3.1
39
+ -------------
40
+
41
+ - Fix multi-process memory monitoring on CentOS 6.x [#3063]
42
+ - Polish the new encryption feature a bit.
43
+
44
+ 1.3.0
45
+ -------------
46
+
47
+ - **BETA** [New encryption feature](https://github.com/mperham/sidekiq/wiki/Ent-Encryption)
48
+ which automatically encrypts the last argument of a Worker, aka the secret bag.
49
+
50
+ 1.2.4
51
+ -------------
52
+
53
+ - Fix issue causing some minutely jobs to execute every other minute.
54
+ - Log a warning if slow periodic processing causes us to miss a clock tick.
55
+
56
+ 1.2.3
7
57
  -------------
8
58
 
9
59
  - Periodic jobs could stop executing until process restart if Redis goes down [#3047]
data/Gemfile CHANGED
@@ -1,11 +1,11 @@
1
1
  source 'https://rubygems.org'
2
2
  gemspec
3
3
 
4
+ gem 'rails', '>= 5.0.1'
4
5
  gem "hiredis"
5
- gem 'rails', '~> 4.2'
6
6
  gem 'simplecov'
7
7
  gem 'minitest'
8
- gem 'minitest-utils'
8
+ #gem 'minitest-utils'
9
9
  gem 'toxiproxy'
10
10
 
11
11
  platforms :rbx do
@@ -23,7 +23,7 @@ platforms :mri do
23
23
  gem 'ruby-prof'
24
24
  end
25
25
 
26
- platforms :jruby do
27
- gem 'jruby-openssl'
28
- gem 'activerecord-jdbcsqlite3-adapter'
29
- end
26
+ #platforms :jruby do
27
+ #gem 'jruby-openssl'
28
+ #gem 'activerecord-jdbcsqlite3-adapter'
29
+ #end
data/Pro-Changes.md CHANGED
@@ -3,6 +3,75 @@ Sidekiq Pro Changelog
3
3
 
4
4
  Please see [http://sidekiq.org/](http://sidekiq.org/) for more details and how to buy.
5
5
 
6
+ HEAD
7
+ ---------
8
+
9
+ - Make Batch UI progress bar more friendly to the colorblind [#3387]
10
+
11
+ 3.4.5
12
+ ---------
13
+
14
+ - Fix potential job loss with reliable scheduler when lots of jobs are scheduled
15
+ at precisely the same time. Thanks to raivil for his hard work in
16
+ reproducing the bug. [#3371]
17
+
18
+ 3.4.4
19
+ ---------
20
+
21
+ - Optimize super\_fetch shutdown to restart jobs quicker [#3249]
22
+
23
+ 3.4.3
24
+ ---------
25
+
26
+ - Limit reliable scheduler to enqueue up to 100 jobs per call, minimizing Redis latency [#3332]
27
+ - Fix bug in super\_fetch logic for queues with `_` in the name [#3339]
28
+
29
+ 3.4.2
30
+ ---------
31
+
32
+ - Add `Batch::Status#invalidated?` API which returns true if any/all
33
+ JIDs were invalidated within the batch. [#3326]
34
+
35
+ 3.4.1
36
+ ---------
37
+
38
+ - Allow super\_fetch's orphan job check to happen as often as every hour [#3273]
39
+ - Officially deprecate reliable\_fetch algorithm, I now recommend you use `super_fetch` instead:
40
+ ```ruby
41
+ Sidekiq.configure_server do |config|
42
+ config.super_fetch!
43
+ end
44
+ ```
45
+ Also note that Sidekiq's `-i/--index` option is no longer used/relevant with super\_fetch.
46
+ - Don't display "Delete/Retry All" buttons when filtering in Web UI [#3243]
47
+ - Reimplement Sidekiq::JobSet#find\_job with ZSCAN [#3197]
48
+
49
+ 3.4.0
50
+ ---------
51
+
52
+ - Introducing the newest reliable fetching algorithm: `super_fetch`! This
53
+ algorithm will replace reliable\_fetch in Pro 4.0. super\_fetch is
54
+ bullet-proof across all environments, no longer requiring stable
55
+ hostnames or an index to be set per-process. [#3077]
56
+ ```ruby
57
+ Sidekiq.configure_server do |config|
58
+ config.super_fetch!
59
+ end
60
+ ```
61
+ Thank you to @jonhyman for code review and the Sidekiq Pro customers that
62
+ beta tested super\_fetch.
63
+
64
+ 3.3.3
65
+ ---------
66
+
67
+ - Update Web UI extension to work with Sidekiq 4.2.0's new Web UI. [#3075]
68
+
69
+ 3.3.2
70
+ ---------
71
+
72
+ - Minimize batch memory usage after success [#3083]
73
+ - Extract batch's 24 hr linger expiry to a LINGER constant so it can be tuned. [#3011]
74
+
6
75
  3.3.1
7
76
  ---------
8
77
 
data/README.md CHANGED
@@ -50,7 +50,8 @@ Getting Started
50
50
  -----------------
51
51
 
52
52
  See the [Getting Started wiki page](https://github.com/mperham/sidekiq/wiki/Getting-Started) and follow the simple setup process.
53
- You can watch [Railscast #366](http://railscasts.com/episodes/366-sidekiq) to see Sidekiq in action. If you do everything right, you should see this:
53
+ You can watch [this Youtube playlist](https://www.youtube.com/playlist?list=PLjeHh2LSCFrWGT5uVjUuFKAcrcj5kSai1) to learn all about
54
+ Sidekiq and see its features in action. Here's the Web UI:
54
55
 
55
56
  ![Web UI](https://github.com/mperham/sidekiq/raw/master/examples/web-ui.png)
56
57
 
@@ -84,8 +85,8 @@ Useful resources:
84
85
 
85
86
  **No support via Twitter, 140 characters is not enough.**
86
87
 
87
- Every Friday morning 9am Pacific is Sidekiq happy hour: I video chat and answer questions.
88
- See the [Sidekiq support page](http://sidekiq.org/support).
88
+ Every Friday morning is Sidekiq happy hour: I video chat and answer questions.
89
+ See the [Sidekiq support page](http://sidekiq.org/support) for details.
89
90
 
90
91
  Thanks
91
92
  -----------------
data/Rakefile CHANGED
@@ -1,9 +1,12 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rake/testtask'
3
3
  Rake::TestTask.new(:test) do |test|
4
- #SO MUCH NOISE
5
- #test.warning = true
4
+ test.warning = true
6
5
  test.pattern = 'test/**/test_*.rb'
7
6
  end
8
7
 
9
8
  task :default => :test
9
+
10
+ task :appraise do
11
+ exec("cd myapp && rake appraise")
12
+ end
data/bin/sidekiqload CHANGED
@@ -12,22 +12,9 @@ require_relative '../lib/sidekiq/launcher'
12
12
 
13
13
  include Sidekiq::Util
14
14
 
15
- # brew tap shopify/shopify
16
- # brew install toxiproxy
17
- # gem install toxiproxy
18
- require 'toxiproxy'
19
- # simulate a non-localhost network for realer-world conditions.
20
- # adding 1ms of network latency has an ENORMOUS impact on benchmarks
21
- Toxiproxy.populate([{
22
- "name": "redis",
23
- "listen": "127.0.0.1:6380",
24
- "upstream": "127.0.0.1:6379"
25
- }])
26
-
27
-
28
15
  Sidekiq.configure_server do |config|
29
16
  #config.options[:concurrency] = 1
30
- config.redis = { driver: :hiredis, db: 13, port: 6380 }
17
+ config.redis = { db: 13 }
31
18
  config.options[:queues] << 'default'
32
19
  config.logger.level = Logger::ERROR
33
20
  config.average_scheduled_poll_interval = 2
@@ -49,14 +36,14 @@ end
49
36
  # brew tap shopify/shopify
50
37
  # brew install toxiproxy
51
38
  # gem install toxiproxy
52
- require 'toxiproxy'
39
+ #require 'toxiproxy'
53
40
  # simulate a non-localhost network for realer-world conditions.
54
41
  # adding 1ms of network latency has an ENORMOUS impact on benchmarks
55
- Toxiproxy.populate([{
56
- "name": "redis",
57
- "listen": "127.0.0.1:6380",
58
- "upstream": "127.0.0.1:6379"
59
- }])
42
+ #Toxiproxy.populate([{
43
+ #"name": "redis",
44
+ #"listen": "127.0.0.1:6380",
45
+ #"upstream": "127.0.0.1:6379"
46
+ #}])
60
47
 
61
48
  self_read, self_write = IO.pipe
62
49
  %w(INT TERM USR1 USR2 TTIN).each do |sig|
@@ -121,7 +108,7 @@ Sidekiq.logger.error "Created #{count*iter} jobs"
121
108
  Monitoring = Thread.new do
122
109
  watchdog("monitor thread") do
123
110
  while true
124
- sleep 2
111
+ sleep 1
125
112
  qsize, retries = Sidekiq.redis do |conn|
126
113
  conn.pipelined do
127
114
  conn.llen "queue:default"
@@ -143,8 +130,8 @@ begin
143
130
  #RubyProf::exclude_threads = [ Monitoring ]
144
131
  #RubyProf.start
145
132
  fire_event(:startup)
146
- Sidekiq.logger.error "Simulating 1ms of latency between Sidekiq and redis"
147
- Toxiproxy[:redis].downstream(:latency, latency: 1).apply do
133
+ #Sidekiq.logger.error "Simulating 1ms of latency between Sidekiq and redis"
134
+ #Toxiproxy[:redis].downstream(:latency, latency: 1).apply do
148
135
  launcher = Sidekiq::Launcher.new(Sidekiq.options)
149
136
  launcher.run
150
137
 
@@ -152,7 +139,7 @@ begin
152
139
  signal = readable_io.first[0].gets.strip
153
140
  handle_signal(launcher, signal)
154
141
  end
155
- end
142
+ #end
156
143
  rescue SystemExit => e
157
144
  #Sidekiq.logger.error("Profiling...")
158
145
  #result = RubyProf.stop
@@ -1,4 +1,4 @@
1
- require_relative 'test_helper'
1
+ require 'test_helper'
2
2
  <% module_namespacing do -%>
3
3
  class <%= class_name %>WorkerTest < <% if defined? Minitest::Test %>Minitest::Test<% else %>MiniTest::Unit::TestCase<% end %>
4
4
  def test_example
data/lib/sidekiq/api.rb CHANGED
@@ -1,5 +1,5 @@
1
- # frozen_string_literal: true
2
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
3
3
  require 'sidekiq'
4
4
 
5
5
  module Sidekiq
@@ -75,7 +75,10 @@ module Sidekiq
75
75
  enqueued = pipe2_res[s..-1].map(&:to_i).inject(0, &:+)
76
76
 
77
77
  default_queue_latency = if (entry = pipe1_res[6].first)
78
- Time.now.to_f - Sidekiq.load_json(entry)['enqueued_at'.freeze]
78
+ job = Sidekiq.load_json(entry)
79
+ now = Time.now.to_f
80
+ thence = job['enqueued_at'.freeze] || now
81
+ now - thence
79
82
  else
80
83
  0
81
84
  end
@@ -225,7 +228,10 @@ module Sidekiq
225
228
  conn.lrange(@rname, -1, -1)
226
229
  end.first
227
230
  return 0 unless entry
228
- Time.now.to_f - Sidekiq.load_json(entry)['enqueued_at']
231
+ job = Sidekiq.load_json(entry)
232
+ now = Time.now.to_f
233
+ thence = job['enqueued_at'] || now
234
+ now - thence
229
235
  end
230
236
 
231
237
  def each
@@ -351,7 +357,8 @@ module Sidekiq
351
357
  end
352
358
 
353
359
  def latency
354
- Time.now.to_f - (@item['enqueued_at'] || @item['created_at'])
360
+ now = Time.now.to_f
361
+ now - (@item['enqueued_at'] || @item['created_at'] || now)
355
362
  end
356
363
 
357
364
  ##
@@ -416,10 +423,9 @@ module Sidekiq
416
423
  end
417
424
 
418
425
  def retry
419
- raise "Retry not available on jobs which have not failed" unless item["failed_at"]
420
426
  remove_job do |message|
421
427
  msg = Sidekiq.load_json(message)
422
- msg['retry_count'] -= 1
428
+ msg['retry_count'] -= 1 if msg['retry_count']
423
429
  Sidekiq::Client.push(msg)
424
430
  end
425
431
  end
@@ -427,9 +433,7 @@ module Sidekiq
427
433
  ##
428
434
  # Place job in the dead set
429
435
  def kill
430
- raise 'Kill not available on jobs which have not failed' unless item['failed_at']
431
436
  remove_job do |message|
432
- Sidekiq.logger.info { "Killing job #{message['jid']}" }
433
437
  now = Time.now.to_f
434
438
  Sidekiq.redis do |conn|
435
439
  conn.multi do
@@ -441,6 +445,10 @@ module Sidekiq
441
445
  end
442
446
  end
443
447
 
448
+ def error?
449
+ !!item['error_class']
450
+ end
451
+
444
452
  private
445
453
 
446
454
  def remove_job
@@ -585,13 +593,13 @@ module Sidekiq
585
593
  # Allows enumeration of scheduled jobs within Sidekiq.
586
594
  # Based on this, you can search/filter for jobs. Here's an
587
595
  # example where I'm selecting all jobs of a certain type
588
- # and deleting them from the retry queue.
596
+ # and deleting them from the schedule queue.
589
597
  #
590
598
  # r = Sidekiq::ScheduledSet.new
591
- # r.select do |retri|
592
- # retri.klass == 'Sidekiq::Extensions::DelayedClass' &&
593
- # retri.args[0] == 'User' &&
594
- # retri.args[1] == 'setup_new_subscriber'
599
+ # r.select do |scheduled|
600
+ # scheduled.klass == 'Sidekiq::Extensions::DelayedClass' &&
601
+ # scheduled.args[0] == 'User' &&
602
+ # scheduled.args[1] == 'setup_new_subscriber'
595
603
  # end.map(&:delete)
596
604
  class ScheduledSet < JobSet
597
605
  def initialize
data/lib/sidekiq/cli.rb CHANGED
@@ -1,5 +1,5 @@
1
- # frozen_string_literal: true
2
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
3
3
  $stdout.sync = true
4
4
 
5
5
  require 'yaml'
@@ -52,7 +52,7 @@ module Sidekiq
52
52
 
53
53
  self_read, self_write = IO.pipe
54
54
 
55
- %w(INT TERM USR1 USR2 TTIN).each do |sig|
55
+ %w(INT TERM USR1 USR2 TTIN TSTP).each do |sig|
56
56
  begin
57
57
  trap sig do
58
58
  self_write.puts(sig)
@@ -135,6 +135,10 @@ module Sidekiq
135
135
  when 'USR1'
136
136
  Sidekiq.logger.info "Received USR1, no longer accepting new work"
137
137
  launcher.quiet
138
+ when 'TSTP'
139
+ # USR1 is not available on JVM, allow TSTP as an alternate signal
140
+ Sidekiq.logger.info "Received TSTP, no longer accepting new work"
141
+ launcher.quiet
138
142
  when 'USR2'
139
143
  if Sidekiq.options[:logfile]
140
144
  Sidekiq.logger.info "Received USR2, reopening log file"
@@ -142,7 +146,7 @@ module Sidekiq
142
146
  end
143
147
  when 'TTIN'
144
148
  Thread.list.each do |thread|
145
- Sidekiq.logger.warn "Thread TID-#{thread.object_id.to_s(36)} #{thread['label']}"
149
+ Sidekiq.logger.warn "Thread TID-#{thread.object_id.to_s(36)} #{thread['sidekiq_label']}"
146
150
  if thread.backtrace
147
151
  Sidekiq.logger.warn thread.backtrace.join("\n")
148
152
  else
@@ -208,6 +212,8 @@ module Sidekiq
208
212
  opts = parse_config(cfile).merge(opts) if cfile
209
213
 
210
214
  opts[:strict] = true if opts[:strict].nil?
215
+ opts[:concurrency] = Integer(ENV["RAILS_MAX_THREADS"]) if !opts[:concurrency] && ENV["RAILS_MAX_THREADS"]
216
+ opts[:identity] = identity
211
217
 
212
218
  options.merge!(opts)
213
219
  end
@@ -227,18 +233,26 @@ module Sidekiq
227
233
  require 'sidekiq/rails'
228
234
  require File.expand_path("#{options[:require]}/config/environment.rb")
229
235
  ::Rails.application.eager_load!
230
- else
236
+ elsif ::Rails::VERSION::MAJOR == 4
231
237
  # Painful contortions, see 1791 for discussion
238
+ # No autoloading, we want to force eager load for everything.
232
239
  require File.expand_path("#{options[:require]}/config/application.rb")
233
240
  ::Rails::Application.initializer "sidekiq.eager_load" do
234
241
  ::Rails.application.config.eager_load = true
235
242
  end
236
243
  require 'sidekiq/rails'
237
244
  require File.expand_path("#{options[:require]}/config/environment.rb")
245
+ else
246
+ # Rails 5+ && development mode, use Reloader
247
+ require 'sidekiq/rails'
248
+ require File.expand_path("#{options[:require]}/config/environment.rb")
238
249
  end
239
250
  options[:tag] ||= default_tag
240
251
  else
241
- require options[:require]
252
+ not_required_message = "#{options[:require]} was not required, you should use an explicit path: " +
253
+ "./#{options[:require]} or /path/to/#{options[:require]}"
254
+
255
+ require(options[:require]) || raise(ArgumentError, not_required_message)
242
256
  end
243
257
  end
244
258
 
@@ -104,3 +104,16 @@ rescue LoadError
104
104
  end
105
105
 
106
106
 
107
+ begin
108
+ require 'active_support/core_ext/kernel/reporting'
109
+ rescue LoadError
110
+ module Kernel
111
+ module_function
112
+ def silence_warnings
113
+ old_verbose, $VERBOSE = $VERBOSE, nil
114
+ yield
115
+ ensure
116
+ $VERBOSE = old_verbose
117
+ end
118
+ end
119
+ end