sidekiq 5.2.9 → 6.2.1

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 (92) hide show
  1. checksums.yaml +4 -4
  2. data/Changes.md +232 -0
  3. data/README.md +18 -34
  4. data/bin/sidekiq +26 -2
  5. data/bin/sidekiqload +32 -24
  6. data/bin/sidekiqmon +8 -0
  7. data/lib/generators/sidekiq/templates/worker_test.rb.erb +1 -1
  8. data/lib/generators/sidekiq/worker_generator.rb +21 -13
  9. data/lib/sidekiq/api.rb +257 -219
  10. data/lib/sidekiq/cli.rb +144 -180
  11. data/lib/sidekiq/client.rb +64 -48
  12. data/lib/sidekiq/delay.rb +5 -6
  13. data/lib/sidekiq/exception_handler.rb +10 -12
  14. data/lib/sidekiq/extensions/action_mailer.rb +13 -22
  15. data/lib/sidekiq/extensions/active_record.rb +13 -10
  16. data/lib/sidekiq/extensions/class_methods.rb +14 -11
  17. data/lib/sidekiq/extensions/generic_proxy.rb +4 -4
  18. data/lib/sidekiq/fetch.rb +38 -31
  19. data/lib/sidekiq/job_logger.rb +45 -7
  20. data/lib/sidekiq/job_retry.rb +62 -61
  21. data/lib/sidekiq/launcher.rb +142 -52
  22. data/lib/sidekiq/logger.rb +166 -0
  23. data/lib/sidekiq/manager.rb +11 -13
  24. data/lib/sidekiq/middleware/chain.rb +15 -5
  25. data/lib/sidekiq/middleware/i18n.rb +5 -7
  26. data/lib/sidekiq/monitor.rb +133 -0
  27. data/lib/sidekiq/paginator.rb +18 -14
  28. data/lib/sidekiq/processor.rb +71 -70
  29. data/lib/sidekiq/rails.rb +29 -37
  30. data/lib/sidekiq/redis_connection.rb +50 -48
  31. data/lib/sidekiq/scheduled.rb +28 -29
  32. data/lib/sidekiq/sd_notify.rb +149 -0
  33. data/lib/sidekiq/systemd.rb +24 -0
  34. data/lib/sidekiq/testing/inline.rb +2 -1
  35. data/lib/sidekiq/testing.rb +35 -24
  36. data/lib/sidekiq/util.rb +45 -16
  37. data/lib/sidekiq/version.rb +2 -1
  38. data/lib/sidekiq/web/action.rb +15 -11
  39. data/lib/sidekiq/web/application.rb +84 -74
  40. data/lib/sidekiq/web/csrf_protection.rb +180 -0
  41. data/lib/sidekiq/web/helpers.rb +108 -79
  42. data/lib/sidekiq/web/router.rb +23 -19
  43. data/lib/sidekiq/web.rb +60 -105
  44. data/lib/sidekiq/worker.rb +126 -102
  45. data/lib/sidekiq.rb +69 -44
  46. data/sidekiq.gemspec +23 -16
  47. data/web/assets/images/apple-touch-icon.png +0 -0
  48. data/web/assets/javascripts/application.js +25 -27
  49. data/web/assets/javascripts/dashboard.js +4 -23
  50. data/web/assets/stylesheets/application-dark.css +160 -0
  51. data/web/assets/stylesheets/application.css +33 -8
  52. data/web/locales/de.yml +14 -2
  53. data/web/locales/en.yml +2 -0
  54. data/web/locales/fr.yml +3 -3
  55. data/web/locales/ja.yml +4 -1
  56. data/web/locales/lt.yml +83 -0
  57. data/web/locales/pl.yml +4 -4
  58. data/web/locales/ru.yml +4 -0
  59. data/web/locales/vi.yml +83 -0
  60. data/web/views/_job_info.erb +2 -1
  61. data/web/views/busy.erb +51 -17
  62. data/web/views/dead.erb +2 -2
  63. data/web/views/layout.erb +2 -0
  64. data/web/views/morgue.erb +5 -2
  65. data/web/views/queue.erb +11 -2
  66. data/web/views/queues.erb +9 -1
  67. data/web/views/retries.erb +5 -2
  68. data/web/views/retry.erb +2 -2
  69. data/web/views/scheduled.erb +5 -2
  70. metadata +27 -60
  71. data/.circleci/config.yml +0 -61
  72. data/.github/contributing.md +0 -32
  73. data/.github/issue_template.md +0 -11
  74. data/.gitignore +0 -15
  75. data/.travis.yml +0 -11
  76. data/3.0-Upgrade.md +0 -70
  77. data/4.0-Upgrade.md +0 -53
  78. data/5.0-Upgrade.md +0 -56
  79. data/COMM-LICENSE +0 -97
  80. data/Ent-Changes.md +0 -238
  81. data/Gemfile +0 -23
  82. data/Pro-2.0-Upgrade.md +0 -138
  83. data/Pro-3.0-Upgrade.md +0 -44
  84. data/Pro-4.0-Upgrade.md +0 -35
  85. data/Pro-Changes.md +0 -759
  86. data/Rakefile +0 -9
  87. data/bin/sidekiqctl +0 -20
  88. data/code_of_conduct.md +0 -50
  89. data/lib/sidekiq/core_ext.rb +0 -1
  90. data/lib/sidekiq/ctl.rb +0 -221
  91. data/lib/sidekiq/logging.rb +0 -122
  92. data/lib/sidekiq/middleware/server/active_record.rb +0 -23
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 575db4e3e544aee9b13d0cd23610bf39c4167e3a9835d4c046a9b355d2cb9c0e
4
- data.tar.gz: 3f1f5806001515d03e206ce8d0695e59f9ff563ac5d84472294799424187591c
3
+ metadata.gz: 298711914bcb8534a9599c47b00b7410467ce324619ee70e7050d15c42f4c329
4
+ data.tar.gz: '007900de7a1558633520c61870a58eff341e9c11009441dbabe0fbc177e4ed99'
5
5
  SHA512:
6
- metadata.gz: 525fe03fcc6911d231696182d46de5da5d4c072681c924b14a0732aeb6aed3a1310baa4f9827f0f50925b69bede7218d485c4a81ebeb2feb712881b39da996e7
7
- data.tar.gz: 586fb51fff5bfefaa6db779e470b6040c8d98a2d4e8fb319cde6087c3f02ffc242ae0a067e32cb8f25585cd6d8d6c12e40f05507514b9406bdb1eadb3ac6f2dd
6
+ metadata.gz: 592ecc114de13f0e43bba9193e1ffd3a973c89a43fac3ed1b750b6a70e29b5bf128a05657baf3fc2ccb77134f092efac055651907f01c0ed6d3c00d45a5ebdc9
7
+ data.tar.gz: a7baed1f1df451e8bd5183fec4631e49c0761e700c4c95fc070389894894a5fb90103d0adce29da797bc1cae72f8a1f21e71da0279e8c18cb62e3b3b5ae05f0a
data/Changes.md CHANGED
@@ -2,6 +2,238 @@
2
2
 
3
3
  [Sidekiq Changes](https://github.com/mperham/sidekiq/blob/master/Changes.md) | [Sidekiq Pro Changes](https://github.com/mperham/sidekiq/blob/master/Pro-Changes.md) | [Sidekiq Enterprise Changes](https://github.com/mperham/sidekiq/blob/master/Ent-Changes.md)
4
4
 
5
+ 6.2.1
6
+ ---------
7
+
8
+ - Update RTT warning logic to handle transient RTT spikes [#4851]
9
+ - Fix very low priority CVE on unescaped queue name [#4852]
10
+ - Add note about sessions and Rails apps in API mode
11
+
12
+ 6.2.0
13
+ ---------
14
+
15
+ - Store Redis RTT and log if poor [#4824]
16
+ - Add process/thread stats to Busy page [#4806]
17
+ - Improve Web UI on mobile devices [#4840]
18
+ - **Refactor Web UI session usage** [#4804]
19
+ Numerous people have hit "Forbidden" errors and struggled with Sidekiq's
20
+ Web UI session requirement. If you have code in your initializer for
21
+ Web sessions, it's quite possible it will need to be removed. Here's
22
+ an overview:
23
+ ```
24
+ Sidekiq::Web needs a valid Rack session for CSRF protection. If this is a Rails app,
25
+ make sure you mount Sidekiq::Web *inside* your routes in `config/routes.rb` so
26
+ Sidekiq can reuse the Rails session:
27
+
28
+ Rails.application.routes.draw do
29
+ mount Sidekiq::Web => "/sidekiq"
30
+ ....
31
+ end
32
+
33
+ If this is a bare Rack app, use a session middleware before Sidekiq::Web:
34
+
35
+ # first, use IRB to create a shared secret key for sessions and commit it
36
+ require 'securerandom'; File.open(".session.key", "w") {|f| f.write(SecureRandom.hex(32)) }
37
+
38
+ # now, update your Rack app to include the secret with a session cookie middleware
39
+ use Rack::Session::Cookie, secret: File.read(".session.key"), same_site: true, max_age: 86400
40
+ run Sidekiq::Web
41
+
42
+ If this is a Rails app in API mode, you need to enable sessions.
43
+
44
+ https://guides.rubyonrails.org/api_app.html#using-session-middlewares
45
+ ```
46
+
47
+ 6.1.3
48
+ ---------
49
+
50
+ - Warn if Redis is configured to evict data under memory pressure [#4752]
51
+ - Add process RSS on the Busy page [#4717]
52
+
53
+ 6.1.2
54
+ ---------
55
+
56
+ - Improve readability in dark mode Web UI [#4674]
57
+ - Fix Web UI crash with corrupt session [#4672]
58
+ - Allow middleware to yield arguments [#4673, @eugeneius]
59
+ - Migrate CI from CircleCI to GitHub Actions [#4677]
60
+
61
+ 6.1.1
62
+ ---------
63
+
64
+ - Jobs are now sorted by age in the Busy Workers table. [#4641]
65
+ - Fix "check all" JS logic in Web UI [#4619]
66
+
67
+ 6.1.0
68
+ ---------
69
+
70
+ - Web UI - Dark Mode fixes [#4543, natematykiewicz]
71
+ - Ensure `Rack::ContentLength` is loaded as middleware for correct Web UI responses [#4541]
72
+ - Avoid exception dumping SSL store in Redis connection logging [#4532]
73
+ - Better error messages in Sidekiq::Client [#4549]
74
+ - Remove rack-protection, reimplement CSRF protection [#4588]
75
+ - Require redis-rb 4.2 [#4591]
76
+ - Update to jquery 1.12.4 [#4593]
77
+ - Refactor internal fetch logic and API [#4602]
78
+
79
+ 6.0.7
80
+ ---------
81
+
82
+ - Refactor systemd integration to work better with custom binaries [#4511]
83
+ - Don't connect to Redis at process exit if not needed [#4502]
84
+ - Remove Redis connection naming [#4479]
85
+ - Fix Redis Sentinel password redaction [#4499]
86
+ - Add Vietnamese locale (vi) [#4528]
87
+
88
+ 6.0.6
89
+ ---------
90
+
91
+ - **Integrate with systemd's watchdog and notification features** [#4488]
92
+ Set `Type=notify` in [sidekiq.service](https://github.com/mperham/sidekiq/blob/4b8a8bd3ae42f6e48ae1fdaf95ed7d7af18ed8bb/examples/systemd/sidekiq.service#L30-L39). The integration works automatically.
93
+ - Use `setTimeout` rather than `setInterval` to avoid thundering herd [#4480]
94
+ - Fix edge case where a job can be pushed without a queue.
95
+ - Flush job stats at exit [#4498]
96
+ - Check RAILS_ENV before RACK_ENV [#4493]
97
+ - Add Lithuanian locale [#4476]
98
+
99
+ 6.0.5
100
+ ---------
101
+
102
+ - Fix broken Web UI response when using NewRelic and Rack 2.1.2+. [#4440]
103
+ - Update APIs to use `UNLINK`, not `DEL`. [#4449]
104
+ - Fix Ruby 2.7 warnings [#4412]
105
+ - Add support for `APP_ENV` [[95fa5d9]](https://github.com/mperham/sidekiq/commit/95fa5d90192148026e52ca2902f1b83c70858ce8)
106
+
107
+ 6.0.4
108
+ ---------
109
+
110
+ - Fix ActiveJob's `sidekiq_options` integration [#4404]
111
+ - Sidekiq Pro users will now see a Pause button next to each queue in
112
+ the Web UI, allowing them to pause queues manually [#4374, shayonj]
113
+ - Fix Sidekiq::Workers API unintentional change in 6.0.2 [#4387]
114
+
115
+
116
+ 6.0.3
117
+ ---------
118
+
119
+ - Fix `Sidekiq::Client.push_bulk` API which was erroneously putting
120
+ invalid `at` values in the job payloads [#4321]
121
+
122
+ 6.0.2
123
+ ---------
124
+
125
+ - Fix Sidekiq Enterprise's rolling restart functionality, broken by refactoring in 6.0.0. [#4334]
126
+ - More internal refactoring and performance tuning [fatkodima]
127
+
128
+ 6.0.1
129
+ ---------
130
+
131
+ - **Performance tuning**, Sidekiq should be 10-15% faster now [#4303, 4299,
132
+ 4269, fatkodima]
133
+ - **Dark Mode support in Web UI** (further design polish welcome!) [#4227, mperham,
134
+ fatkodima, silent-e]
135
+ - **Job-specific log levels**, allowing you to turn on debugging for
136
+ problematic workers. [fatkodima, #4287]
137
+ ```ruby
138
+ MyWorker.set(log_level: :debug).perform_async(...)
139
+ ```
140
+ - **Ad-hoc job tags**. You can tag your jobs with, e.g, subdomain, tenant, country,
141
+ locale, application, version, user/client, "alpha/beta/pro/ent", types of jobs,
142
+ teams/people responsible for jobs, additional metadata, etc.
143
+ Tags are shown on different pages with job listings. Sidekiq Pro users
144
+ can filter based on them [fatkodima, #4280]
145
+ ```ruby
146
+ class MyWorker
147
+ include Sidekiq::Worker
148
+ sidekiq_options tags: ['bank-ops', 'alpha']
149
+ ...
150
+ end
151
+ ```
152
+ - Fetch scheduled jobs in batches before pushing into specific queues.
153
+ This will decrease enqueueing time of scheduled jobs by a third. [fatkodima, #4273]
154
+ ```
155
+ ScheduledSet with 10,000 jobs
156
+ Before: 56.6 seconds
157
+ After: 39.2 seconds
158
+ ```
159
+ - Compress error backtraces before pushing into Redis, if you are
160
+ storing error backtraces, this will halve the size of your RetrySet
161
+ in Redis [fatkodima, #4272]
162
+ ```
163
+ RetrySet with 100,000 jobs
164
+ Before: 261 MB
165
+ After: 129 MB
166
+ ```
167
+ - Support display of ActiveJob 6.0 payloads in the Web UI [#4263]
168
+ - Add `SortedSet#scan` for pattern based scanning. For large sets this API will be **MUCH** faster
169
+ than standard iteration using each. [fatkodima, #4262]
170
+ ```ruby
171
+ Sidekiq::DeadSet.new.scan("UnreliableApi") do |job|
172
+ job.retry
173
+ end
174
+ ```
175
+ - Dramatically speed up SortedSet#find\_job(jid) by using Redis's ZSCAN
176
+ support, approx 10x faster. [fatkodima, #4259]
177
+ ```
178
+ zscan 0.179366 0.047727 0.227093 ( 1.161376)
179
+ enum 8.522311 0.419826 8.942137 ( 9.785079)
180
+ ```
181
+ - Respect rails' generators `test_framework` option and gracefully handle extra `worker` suffix on generator [fatkodima, #4256]
182
+ - Add ability to sort 'Enqueued' page on Web UI by position in the queue [fatkodima, #4248]
183
+ - Support `Client.push_bulk` with different delays [fatkodima, #4243]
184
+ ```ruby
185
+ Sidekiq::Client.push_bulk("class" => FooJob, "args" => [[1], [2]], "at" => [1.minute.from_now.to_f, 5.minutes.from_now.to_f])
186
+ ```
187
+ - Easier way to test enqueuing specific ActionMailer and ActiveRecord delayed jobs. Instead of manually
188
+ parsing embedded class, you can now test by fetching jobs for specific classes. [fatkodima, #4292]
189
+ ```ruby
190
+ assert_equal 1, Sidekiq::Extensions::DelayedMailer.jobs_for(FooMailer).size
191
+ ```
192
+ - Add `sidekiqmon` to gemspec executables [#4242]
193
+ - Gracefully handle `Sidekiq.logger = nil` [#4240]
194
+ - Inject Sidekiq::LogContext module if user-supplied logger does not include it [#4239]
195
+
196
+ 6.0
197
+ ---------
198
+
199
+ This release has major breaking changes. Read and test carefully in production.
200
+
201
+ - With Rails 6.0.2+, ActiveJobs can now use `sidekiq_options` directly to configure Sidekiq
202
+ features/internals like the retry subsystem. [#4213, pirj]
203
+ ```ruby
204
+ class MyJob < ActiveJob::Base
205
+ queue_as :myqueue
206
+ sidekiq_options retry: 10, backtrace: 20
207
+ def perform(...)
208
+ end
209
+ end
210
+ ```
211
+ - Logging has been redesigned to allow for pluggable log formatters:
212
+ ```ruby
213
+ Sidekiq.configure_server do |config|
214
+ config.log_formatter = Sidekiq::Logger::Formatters::JSON.new
215
+ end
216
+ ```
217
+ See the [Logging wiki page](https://github.com/mperham/sidekiq/wiki/Logging) for more details.
218
+ - **BREAKING CHANGE** Validate proper usage of the `REDIS_PROVIDER`
219
+ variable. This variable is meant to hold the name of the environment
220
+ variable which contains your Redis URL, so that you can switch Redis
221
+ providers quickly and easily with a single variable change. It is not
222
+ meant to hold the actual Redis URL itself. If you want to manually set
223
+ the Redis URL (not recommended as it implies you have no failover),
224
+ then you may set `REDIS_URL` directly. [#3969]
225
+ - **BREAKING CHANGE** Increase default shutdown timeout from 8 seconds
226
+ to 25 seconds. Both Heroku and ECS now use 30 second shutdown timeout
227
+ by default and we want Sidekiq to take advantage of this time. If you
228
+ have deployment scripts which depend on the old default timeout, use `-t 8` to
229
+ get the old behavior. [#3968]
230
+ - **BREAKING CHANGE** Remove the daemonization, logfile and pidfile
231
+ arguments to Sidekiq. Use a proper process supervisor (e.g. systemd or
232
+ foreman) to manage Sidekiq. See the Deployment wiki page for links to
233
+ more resources.
234
+ - Integrate the StandardRB code formatter to ensure consistent code
235
+ styling. [#4114, gearnode]
236
+
5
237
  5.2.9
6
238
  ---------
7
239
 
data/README.md CHANGED
@@ -2,10 +2,7 @@ Sidekiq
2
2
  ==============
3
3
 
4
4
  [![Gem Version](https://badge.fury.io/rb/sidekiq.svg)](https://rubygems.org/gems/sidekiq)
5
- [![Code Climate](https://codeclimate.com/github/mperham/sidekiq.svg)](https://codeclimate.com/github/mperham/sidekiq)
6
- [![Build Status](https://circleci.com/gh/mperham/sidekiq/tree/master.svg?style=svg)](https://circleci.com/gh/mperham/sidekiq/tree/master)
7
- [![Gitter Chat](https://badges.gitter.im/mperham/sidekiq.svg)](https://gitter.im/mperham/sidekiq)
8
-
5
+ ![Build](https://github.com/mperham/sidekiq/workflows/CI/badge.svg)
9
6
 
10
7
  Simple, efficient background processing for Ruby.
11
8
 
@@ -13,32 +10,27 @@ Sidekiq uses threads to handle many jobs at the same time in the
13
10
  same process. It does not require Rails but will integrate tightly with
14
11
  Rails to make background processing dead simple.
15
12
 
16
- Sidekiq is compatible with Resque. It uses the exact same
17
- message format as Resque so it can integrate into an existing Resque processing farm.
18
- You can have Sidekiq and Resque run side-by-side at the same time and
19
- use the Resque client to enqueue jobs in Redis to be processed by Sidekiq.
20
-
21
13
  Performance
22
14
  ---------------
23
15
 
24
- Version | Latency | Garbage created for 10,000 jobs | Time to process 100,000 jobs | Throughput
25
- -----------------|------|---------|---------|------------------------
26
- Sidekiq 4.0.0 | 10ms | 151 MB | 22 sec | **4500 jobs/sec**
27
- Sidekiq 3.5.1 | 22ms | 1257 MB | 125 sec | 800 jobs/sec
28
- Resque 1.25.2 | - | - | 420 sec | 240 jobs/sec
29
- DelayedJob 4.1.1 | - | - | 465 sec | 215 jobs/sec
16
+ Version | Latency | Garbage created for 10k jobs | Time to process 100k jobs | Throughput | Ruby
17
+ -----------------|------|---------|---------|------------------------|-----
18
+ Sidekiq 6.0.2 | 3 ms | 156 MB | 14.0 sec| **7100 jobs/sec** | MRI 2.6.3
19
+ Sidekiq 6.0.0 | 3 ms | 156 MB | 19 sec | 5200 jobs/sec | MRI 2.6.3
20
+ Sidekiq 4.0.0 | 10 ms | 151 MB | 22 sec | 4500 jobs/sec |
21
+ Sidekiq 3.5.1 | 22 ms | 1257 MB | 125 sec | 800 jobs/sec |
22
+ Resque 1.25.2 | - | - | 420 sec | 240 jobs/sec |
23
+ DelayedJob 4.1.1 | - | - | 465 sec | 215 jobs/sec |
30
24
 
31
- <small>This benchmark can be found in `bin/sidekiqload`.</small>
25
+ This benchmark can be found in `bin/sidekiqload` and assumes a Redis network latency of 1ms.
32
26
 
33
27
  Requirements
34
28
  -----------------
35
29
 
36
- Sidekiq supports CRuby 2.2.2+ and JRuby 9k.
30
+ - Redis: 4.0+
31
+ - Ruby: MRI 2.5+ or JRuby 9.2+.
37
32
 
38
- All Rails releases >= 4.0 are officially supported.
39
-
40
- Redis 2.8 or greater is required. 3.0.3+ is recommended for large
41
- installations with thousands of worker threads.
33
+ Sidekiq 6.0 supports Rails 5.0+ but does not require it.
42
34
 
43
35
 
44
36
  Installation
@@ -63,7 +55,7 @@ Want to Upgrade?
63
55
  I also sell Sidekiq Pro and Sidekiq Enterprise, extensions to Sidekiq which provide more
64
56
  features, a commercial-friendly license and allow you to support high
65
57
  quality open source development all at the same time. Please see the
66
- [Sidekiq](http://sidekiq.org/) homepage for more detail.
58
+ [Sidekiq](https://sidekiq.org/) homepage for more detail.
67
59
 
68
60
  Subscribe to the **[quarterly newsletter](https://tinyletter.com/sidekiq)** to stay informed about the latest
69
61
  features and changes to Sidekiq and its bigger siblings.
@@ -77,24 +69,16 @@ Problems?
77
69
  If you have a problem, please review the [FAQ](https://github.com/mperham/sidekiq/wiki/FAQ) and [Troubleshooting](https://github.com/mperham/sidekiq/wiki/Problems-and-Troubleshooting) wiki pages.
78
70
  Searching the [issues](https://github.com/mperham/sidekiq/issues) for your problem is also a good idea.
79
71
 
80
- Sidekiq Pro and Sidekiq Enterprise customers get private email support. You can purchase at http://sidekiq.org; email support@contribsys.com for help.
72
+ Sidekiq Pro and Sidekiq Enterprise customers get private email support. You can purchase at https://sidekiq.org; email support@contribsys.com for help.
81
73
 
82
74
  Useful resources:
83
75
 
84
76
  * Product documentation is in the [wiki](https://github.com/mperham/sidekiq/wiki).
85
- * Release announcements are made to the [@sidekiq](https://twitter.com/sidekiq) Twitter account.
77
+ * Occasional announcements are made to the [@sidekiq](https://twitter.com/sidekiq) Twitter account.
86
78
  * The [Sidekiq tag](https://stackoverflow.com/questions/tagged/sidekiq) on Stack Overflow has lots of useful Q &amp; A.
87
79
 
88
- **No support via Twitter**
89
-
90
80
  Every Friday morning is Sidekiq happy hour: I video chat and answer questions.
91
- See the [Sidekiq support page](http://sidekiq.org/support.html) for details.
92
-
93
- Thanks
94
- -----------------
95
-
96
- Sidekiq stays fast by using the [JProfiler java profiler](http://www.ej-technologies.com/products/jprofiler/overview.html) to find and fix
97
- performance problems on JRuby. Unfortunately MRI does not have good multithreaded profiling tools.
81
+ See the [Sidekiq support page](https://sidekiq.org/support.html) for details.
98
82
 
99
83
 
100
84
  License
@@ -106,4 +90,4 @@ Please see [LICENSE](https://github.com/mperham/sidekiq/blob/master/LICENSE) for
106
90
  Author
107
91
  -----------------
108
92
 
109
- Mike Perham, [@mperham](https://twitter.com/mperham) / [@sidekiq](https://twitter.com/sidekiq), [http://www.mikeperham.com](http://www.mikeperham.com) / [http://www.contribsys.com](http://www.contribsys.com)
93
+ Mike Perham, [@getajobmike](https://twitter.com/getajobmike) / [@sidekiq](https://twitter.com/sidekiq), [https://www.mikeperham.com](https://www.mikeperham.com) / [https://www.contribsys.com](https://www.contribsys.com)
data/bin/sidekiq CHANGED
@@ -6,13 +6,37 @@ $TESTING = false
6
6
 
7
7
  require_relative '../lib/sidekiq/cli'
8
8
 
9
+ def integrate_with_systemd
10
+ return unless ENV["NOTIFY_SOCKET"]
11
+
12
+ Sidekiq.configure_server do |config|
13
+ Sidekiq.logger.info "Enabling systemd notification integration"
14
+ require "sidekiq/sd_notify"
15
+ config.on(:startup) do
16
+ Sidekiq::SdNotify.ready
17
+ end
18
+ config.on(:shutdown) do
19
+ Sidekiq::SdNotify.stopping
20
+ end
21
+ Sidekiq.start_watchdog if Sidekiq::SdNotify.watchdog?
22
+ end
23
+ end
24
+
9
25
  begin
10
26
  cli = Sidekiq::CLI.instance
11
27
  cli.parse
28
+
29
+ integrate_with_systemd
30
+
12
31
  cli.run
13
32
  rescue => e
14
33
  raise e if $DEBUG
15
- STDERR.puts e.message
16
- STDERR.puts e.backtrace.join("\n")
34
+ if Sidekiq.error_handlers.length == 0
35
+ STDERR.puts e.message
36
+ STDERR.puts e.backtrace.join("\n")
37
+ else
38
+ cli.handle_exception e
39
+ end
40
+
17
41
  exit 1
18
42
  end
data/bin/sidekiqload CHANGED
@@ -5,7 +5,8 @@
5
5
  $TESTING = false
6
6
 
7
7
  #require 'ruby-prof'
8
- Bundler.require(:default)
8
+ require 'bundler/setup'
9
+ Bundler.require(:default, :load_test)
9
10
 
10
11
  require_relative '../lib/sidekiq/cli'
11
12
  require_relative '../lib/sidekiq/launcher'
@@ -13,8 +14,8 @@ require_relative '../lib/sidekiq/launcher'
13
14
  include Sidekiq::Util
14
15
 
15
16
  Sidekiq.configure_server do |config|
16
- #config.options[:concurrency] = 1
17
- config.redis = { db: 13 }
17
+ config.options[:concurrency] = 10
18
+ config.redis = { db: 13, port: 6380, driver: :hiredis }
18
19
  config.options[:queues] << 'default'
19
20
  config.logger.level = Logger::ERROR
20
21
  config.average_scheduled_poll_interval = 2
@@ -28,7 +29,8 @@ class LoadWorker
28
29
  1
29
30
  end
30
31
 
31
- def perform(idx)
32
+ def perform(idx, ts=nil)
33
+ puts(Time.now.to_f - ts) if ts != nil
32
34
  #raise idx.to_s if idx % 100 == 1
33
35
  end
34
36
  end
@@ -36,14 +38,15 @@ end
36
38
  # brew tap shopify/shopify
37
39
  # brew install toxiproxy
38
40
  # gem install toxiproxy
39
- #require 'toxiproxy'
41
+ # run `toxiproxy-server` in a separate terminal window.
42
+ require 'toxiproxy'
40
43
  # simulate a non-localhost network for realer-world conditions.
41
44
  # adding 1ms of network latency has an ENORMOUS impact on benchmarks
42
- #Toxiproxy.populate([{
43
- #"name": "redis",
44
- #"listen": "127.0.0.1:6380",
45
- #"upstream": "127.0.0.1:6379"
46
- #}])
45
+ Toxiproxy.populate([{
46
+ "name": "redis",
47
+ "listen": "127.0.0.1:6380",
48
+ "upstream": "127.0.0.1:6379"
49
+ }])
47
50
 
48
51
  self_read, self_write = IO.pipe
49
52
  %w(INT TERM TSTP TTIN).each do |sig|
@@ -100,21 +103,26 @@ iter.times do
100
103
  end
101
104
  Sidekiq.logger.error "Created #{count*iter} jobs"
102
105
 
106
+ start = Time.now
107
+
103
108
  Monitoring = Thread.new do
104
109
  watchdog("monitor thread") do
105
110
  while true
106
- sleep 1
107
- qsize, retries = Sidekiq.redis do |conn|
108
- conn.pipelined do
109
- conn.llen "queue:default"
110
- conn.zcard "retry"
111
- end
112
- end.map(&:to_i)
113
- total = qsize + retries
114
- #GC.start
115
- Sidekiq.logger.error("RSS: #{Process.rss} Pending: #{total}")
111
+ sleep 0.2
112
+ qsize = Sidekiq.redis do |conn|
113
+ conn.llen "queue:default"
114
+ end
115
+ total = qsize
116
+ #Sidekiq.logger.error("RSS: #{Process.rss} Pending: #{total}")
116
117
  if total == 0
117
- Sidekiq.logger.error("Done")
118
+ Sidekiq.logger.error("Done, #{iter * count} jobs in #{Time.now - start} sec")
119
+ Sidekiq.logger.error("Now here's the latency for three jobs")
120
+
121
+ LoadWorker.perform_async(1, Time.now.to_f)
122
+ LoadWorker.perform_async(2, Time.now.to_f)
123
+ LoadWorker.perform_async(3, Time.now.to_f)
124
+
125
+ sleep 0.2
118
126
  exit(0)
119
127
  end
120
128
  end
@@ -125,8 +133,8 @@ begin
125
133
  #RubyProf::exclude_threads = [ Monitoring ]
126
134
  #RubyProf.start
127
135
  fire_event(:startup)
128
- #Sidekiq.logger.error "Simulating 1ms of latency between Sidekiq and redis"
129
- #Toxiproxy[:redis].downstream(:latency, latency: 1).apply do
136
+ Sidekiq.logger.error "Simulating 1ms of latency between Sidekiq and redis"
137
+ Toxiproxy[:redis].downstream(:latency, latency: 1).apply do
130
138
  launcher = Sidekiq::Launcher.new(Sidekiq.options)
131
139
  launcher.run
132
140
 
@@ -134,7 +142,7 @@ begin
134
142
  signal = readable_io.first[0].gets.strip
135
143
  handle_signal(launcher, signal)
136
144
  end
137
- #end
145
+ end
138
146
  rescue SystemExit => e
139
147
  #Sidekiq.logger.error("Profiling...")
140
148
  #result = RubyProf.stop
data/bin/sidekiqmon ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'sidekiq/monitor'
4
+
5
+ section = "all"
6
+ section = ARGV[0] if ARGV.size == 1
7
+
8
+ Sidekiq::Monitor::Status.new.display(section)
@@ -1,6 +1,6 @@
1
1
  require 'test_helper'
2
2
  <% module_namespacing do -%>
3
- class <%= class_name %>WorkerTest < <% if defined? Minitest::Test %>Minitest::Test<% else %>MiniTest::Unit::TestCase<% end %>
3
+ class <%= class_name %>WorkerTest < Minitest::Test
4
4
  def test_example
5
5
  skip "add some examples to (or delete) #{__FILE__}"
6
6
  end
@@ -1,22 +1,24 @@
1
- require 'rails/generators/named_base'
1
+ require "rails/generators/named_base"
2
2
 
3
3
  module Sidekiq
4
4
  module Generators # :nodoc:
5
5
  class WorkerGenerator < ::Rails::Generators::NamedBase # :nodoc:
6
- desc 'This generator creates a Sidekiq Worker in app/workers and a corresponding test'
6
+ desc "This generator creates a Sidekiq Worker in app/workers and a corresponding test"
7
7
 
8
- check_class_collision suffix: 'Worker'
8
+ check_class_collision suffix: "Worker"
9
9
 
10
10
  def self.default_generator_root
11
11
  File.dirname(__FILE__)
12
12
  end
13
13
 
14
14
  def create_worker_file
15
- template 'worker.rb.erb', File.join('app/workers', class_path, "#{file_name}_worker.rb")
15
+ template "worker.rb.erb", File.join("app/workers", class_path, "#{file_name}_worker.rb")
16
16
  end
17
17
 
18
18
  def create_test_file
19
- if defined?(RSpec)
19
+ return unless test_framework
20
+
21
+ if test_framework == :rspec
20
22
  create_worker_spec
21
23
  else
22
24
  create_worker_test
@@ -27,23 +29,29 @@ module Sidekiq
27
29
 
28
30
  def create_worker_spec
29
31
  template_file = File.join(
30
- 'spec/workers',
31
- class_path,
32
- "#{file_name}_worker_spec.rb"
32
+ "spec/workers",
33
+ class_path,
34
+ "#{file_name}_worker_spec.rb"
33
35
  )
34
- template 'worker_spec.rb.erb', template_file
36
+ template "worker_spec.rb.erb", template_file
35
37
  end
36
38
 
37
39
  def create_worker_test
38
40
  template_file = File.join(
39
- 'test/workers',
40
- class_path,
41
- "#{file_name}_worker_test.rb"
41
+ "test/workers",
42
+ class_path,
43
+ "#{file_name}_worker_test.rb"
42
44
  )
43
- template 'worker_test.rb.erb', template_file
45
+ template "worker_test.rb.erb", template_file
44
46
  end
45
47
 
48
+ def file_name
49
+ @_file_name ||= super.sub(/_?worker\z/i, "")
50
+ end
46
51
 
52
+ def test_framework
53
+ ::Rails.application.config.generators.options[:rails][:test_framework]
54
+ end
47
55
  end
48
56
  end
49
57
  end