sidekiq 6.3.1 → 7.0.0
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.
- checksums.yaml +4 -4
- data/Changes.md +140 -4
- data/LICENSE.txt +9 -0
- data/README.md +19 -13
- data/bin/sidekiq +4 -9
- data/bin/sidekiqload +71 -76
- data/bin/sidekiqmon +1 -1
- data/lib/generators/sidekiq/job_generator.rb +57 -0
- data/lib/generators/sidekiq/templates/{worker.rb.erb → job.rb.erb} +2 -2
- data/lib/generators/sidekiq/templates/{worker_spec.rb.erb → job_spec.rb.erb} +1 -1
- data/lib/generators/sidekiq/templates/{worker_test.rb.erb → job_test.rb.erb} +1 -1
- data/lib/sidekiq/api.rb +267 -186
- data/lib/sidekiq/capsule.rb +110 -0
- data/lib/sidekiq/cli.rb +82 -78
- data/lib/sidekiq/client.rb +73 -80
- data/lib/sidekiq/{util.rb → component.rb} +13 -42
- data/lib/sidekiq/config.rb +271 -0
- data/lib/sidekiq/deploy.rb +62 -0
- data/lib/sidekiq/embedded.rb +61 -0
- data/lib/sidekiq/fetch.rb +22 -21
- data/lib/sidekiq/job.rb +375 -10
- data/lib/sidekiq/job_logger.rb +16 -28
- data/lib/sidekiq/job_retry.rb +79 -56
- data/lib/sidekiq/job_util.rb +71 -0
- data/lib/sidekiq/launcher.rb +76 -82
- data/lib/sidekiq/logger.rb +9 -44
- data/lib/sidekiq/manager.rb +40 -41
- data/lib/sidekiq/metrics/query.rb +153 -0
- data/lib/sidekiq/metrics/shared.rb +95 -0
- data/lib/sidekiq/metrics/tracking.rb +134 -0
- data/lib/sidekiq/middleware/chain.rb +84 -42
- data/lib/sidekiq/middleware/current_attributes.rb +19 -13
- data/lib/sidekiq/middleware/i18n.rb +6 -4
- data/lib/sidekiq/middleware/modules.rb +21 -0
- data/lib/sidekiq/monitor.rb +1 -1
- data/lib/sidekiq/paginator.rb +16 -8
- data/lib/sidekiq/processor.rb +56 -59
- data/lib/sidekiq/rails.rb +10 -9
- data/lib/sidekiq/redis_client_adapter.rb +118 -0
- data/lib/sidekiq/redis_connection.rb +13 -82
- data/lib/sidekiq/ring_buffer.rb +29 -0
- data/lib/sidekiq/scheduled.rb +75 -37
- data/lib/sidekiq/testing/inline.rb +4 -4
- data/lib/sidekiq/testing.rb +41 -68
- data/lib/sidekiq/transaction_aware_client.rb +44 -0
- data/lib/sidekiq/version.rb +2 -1
- data/lib/sidekiq/web/action.rb +3 -3
- data/lib/sidekiq/web/application.rb +27 -8
- data/lib/sidekiq/web/csrf_protection.rb +3 -3
- data/lib/sidekiq/web/helpers.rb +22 -20
- data/lib/sidekiq/web.rb +6 -17
- data/lib/sidekiq/worker_compatibility_alias.rb +13 -0
- data/lib/sidekiq.rb +85 -202
- data/sidekiq.gemspec +29 -5
- data/web/assets/javascripts/application.js +58 -26
- data/web/assets/javascripts/base-charts.js +106 -0
- data/web/assets/javascripts/chart.min.js +13 -0
- data/web/assets/javascripts/chartjs-plugin-annotation.min.js +7 -0
- data/web/assets/javascripts/dashboard-charts.js +166 -0
- data/web/assets/javascripts/dashboard.js +3 -240
- data/web/assets/javascripts/metrics.js +236 -0
- data/web/assets/stylesheets/application-dark.css +13 -17
- data/web/assets/stylesheets/application-rtl.css +2 -91
- data/web/assets/stylesheets/application.css +67 -300
- data/web/locales/ar.yml +70 -70
- data/web/locales/cs.yml +62 -62
- data/web/locales/da.yml +52 -52
- data/web/locales/de.yml +65 -65
- data/web/locales/el.yml +43 -24
- data/web/locales/en.yml +82 -69
- data/web/locales/es.yml +68 -68
- data/web/locales/fa.yml +65 -65
- data/web/locales/fr.yml +67 -67
- data/web/locales/he.yml +65 -64
- data/web/locales/hi.yml +59 -59
- data/web/locales/it.yml +53 -53
- data/web/locales/ja.yml +71 -68
- data/web/locales/ko.yml +52 -52
- data/web/locales/lt.yml +66 -66
- data/web/locales/nb.yml +61 -61
- data/web/locales/nl.yml +52 -52
- data/web/locales/pl.yml +45 -45
- data/web/locales/pt-br.yml +63 -55
- data/web/locales/pt.yml +51 -51
- data/web/locales/ru.yml +67 -66
- data/web/locales/sv.yml +53 -53
- data/web/locales/ta.yml +60 -60
- data/web/locales/uk.yml +62 -61
- data/web/locales/ur.yml +64 -64
- data/web/locales/vi.yml +67 -67
- data/web/locales/zh-cn.yml +37 -11
- data/web/locales/zh-tw.yml +42 -8
- data/web/views/_footer.erb +5 -2
- data/web/views/_nav.erb +1 -1
- data/web/views/_summary.erb +1 -1
- data/web/views/busy.erb +9 -4
- data/web/views/dashboard.erb +36 -4
- data/web/views/metrics.erb +80 -0
- data/web/views/metrics_for_job.erb +69 -0
- data/web/views/queue.erb +5 -1
- metadata +75 -27
- data/LICENSE +0 -9
- data/lib/generators/sidekiq/worker_generator.rb +0 -57
- data/lib/sidekiq/delay.rb +0 -41
- data/lib/sidekiq/exception_handler.rb +0 -27
- data/lib/sidekiq/extensions/action_mailer.rb +0 -48
- data/lib/sidekiq/extensions/active_record.rb +0 -43
- data/lib/sidekiq/extensions/class_methods.rb +0 -43
- data/lib/sidekiq/extensions/generic_proxy.rb +0 -33
- data/lib/sidekiq/worker.rb +0 -311
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c6762c97172b3f8e4b7cc1fd940756ee8796faf70ece8d5e9ede9e2dc7797fe
|
4
|
+
data.tar.gz: 905e0e1f381e1c40832ab2137589161fcccfb63c847ad36c9cca15765d952659
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: acfc9bb74585cc65ad1af27e263668ec154ac791baa99de2a1542cfe462a7b13544a758a7bd574d623088c9e683f705437cc4e4495f05e57770037d030214a44
|
7
|
+
data.tar.gz: 31320e6cd2fab0d253f3a32616f51360c4ad6a9ef30acef5f88a6ccc6eaf75e04b76ea12dd053dd29442d96fa49234f65e14801e7600cf0f300c023d75aecf43
|
data/Changes.md
CHANGED
@@ -2,6 +2,135 @@
|
|
2
2
|
|
3
3
|
[Sidekiq Changes](https://github.com/mperham/sidekiq/blob/main/Changes.md) | [Sidekiq Pro Changes](https://github.com/mperham/sidekiq/blob/main/Pro-Changes.md) | [Sidekiq Enterprise Changes](https://github.com/mperham/sidekiq/blob/main/Ent-Changes.md)
|
4
4
|
|
5
|
+
main
|
6
|
+
----------
|
7
|
+
|
8
|
+
- Embedded mode!
|
9
|
+
- Capsules!!
|
10
|
+
- Job Execution metrics!!!
|
11
|
+
- See `docs/7.0-Upgrade.md` for release notes
|
12
|
+
|
13
|
+
6-x
|
14
|
+
----------
|
15
|
+
|
16
|
+
- Add pagination to Busy page [#5556]
|
17
|
+
- Speed up WorkSet#each [#5559]
|
18
|
+
- Adjust CurrentAttributes to work with the String class name so we aren't referencing
|
19
|
+
the Class within a Rails initializer [#5536]
|
20
|
+
|
21
|
+
6.5.7
|
22
|
+
----------
|
23
|
+
|
24
|
+
- Updates for JA and ZH locales
|
25
|
+
- Further optimizations for scheduled polling [#5513]
|
26
|
+
|
27
|
+
6.5.6
|
28
|
+
----------
|
29
|
+
|
30
|
+
- Fix deprecation warnings with redis-rb 4.8.0 [#5484]
|
31
|
+
- Lock redis-rb to < 5.0 as we are moving to redis-client in Sidekiq 7.0
|
32
|
+
|
33
|
+
6.5.5
|
34
|
+
----------
|
35
|
+
|
36
|
+
- Fix require issue with job_retry.rb [#5462]
|
37
|
+
- Improve Sidekiq::Web compatibility with Rack 3.x
|
38
|
+
|
39
|
+
6.5.4
|
40
|
+
----------
|
41
|
+
|
42
|
+
- Fix invalid code on Ruby 2.5 [#5460]
|
43
|
+
- Fix further metrics dependency issues [#5457]
|
44
|
+
|
45
|
+
6.5.3
|
46
|
+
----------
|
47
|
+
|
48
|
+
- Don't require metrics code without explicit opt-in [#5456]
|
49
|
+
|
50
|
+
6.5.2
|
51
|
+
----------
|
52
|
+
|
53
|
+
- [Job Metrics are under active development, help wanted!](https://github.com/mperham/sidekiq/wiki/Metrics#contributing) **BETA**
|
54
|
+
- Add `Context` column on queue page which shows any CurrentAttributes [#5450]
|
55
|
+
- `sidekiq_retry_in` may now return `:discard` or `:kill` to dynamically stop job retries [#5406]
|
56
|
+
- Smarter sorting of processes in /busy Web UI [#5398]
|
57
|
+
- Fix broken hamburger menu in mobile UI [#5428]
|
58
|
+
- Require redis-rb 4.5.0. Note that Sidekiq will break if you use the
|
59
|
+
[`Redis.exists_returns_integer = false`](https://github.com/redis/redis-rb/blob/master/CHANGELOG.md#450) flag. [#5394]
|
60
|
+
|
61
|
+
6.5.1
|
62
|
+
----------
|
63
|
+
|
64
|
+
- Fix `push_bulk` breakage [#5387]
|
65
|
+
|
66
|
+
6.5.0
|
67
|
+
---------
|
68
|
+
|
69
|
+
- Substantial refactoring of Sidekiq server internals, part of a larger effort
|
70
|
+
to reduce Sidekiq's internal usage of global methods and data, see [docs/global_to_local.md](docs/global_to_local.md) and [docs/middleware.md](docs/middleware.md).
|
71
|
+
- **Add beta support for the `redis-client` gem**. This will become the default Redis driver in Sidekiq 7.0. [#5298]
|
72
|
+
Read more: https://github.com/mperham/sidekiq/wiki/Using-redis-client
|
73
|
+
- **Add beta support for DB transaction-aware client** [#5291]
|
74
|
+
Add this line to your initializer and any jobs created during a transaction
|
75
|
+
will only be pushed to Redis **after the transaction commits**. You will need to add the
|
76
|
+
`after_commit_everywhere` gem to your Gemfile.
|
77
|
+
```ruby
|
78
|
+
Sidekiq.transactional_push!
|
79
|
+
```
|
80
|
+
This feature does not have a lot of production usage yet; please try it out and let us
|
81
|
+
know if you have any issues. It will be fully supported in Sidekiq 7.0 or removed if it
|
82
|
+
proves problematic.
|
83
|
+
- Fix regression with middleware arguments [#5312]
|
84
|
+
|
85
|
+
6.4.2
|
86
|
+
---------
|
87
|
+
|
88
|
+
- Strict argument checking now runs after client-side middleware [#5246]
|
89
|
+
- Fix page events with live polling [#5184]
|
90
|
+
- Many under-the-hood changes to remove all usage of the term "worker"
|
91
|
+
from the Sidekiq codebase and APIs. This mostly involved RDoc and local
|
92
|
+
variable names but a few constants and public APIs were changed. The old
|
93
|
+
APIs will be removed in Sidekiq 7.0.
|
94
|
+
```
|
95
|
+
Sidekiq::DEFAULT_WORKER_OPTIONS -> Sidekiq.default_job_options
|
96
|
+
Sidekiq.default_worker_options -> Sidekiq.default_job_options
|
97
|
+
Sidekiq::Queues["default"].jobs_by_worker(HardJob) -> Sidekiq::Queues["default"].jobs_by_class(HardJob)
|
98
|
+
```
|
99
|
+
|
100
|
+
6.4.1
|
101
|
+
---------
|
102
|
+
|
103
|
+
- Fix pipeline/multi deprecations in redis-rb 4.6
|
104
|
+
- Fix sidekiq.yml YAML load errors on Ruby 3.1 [#5141]
|
105
|
+
- Sharding support for `perform_bulk` [#5129]
|
106
|
+
- Refactor job logger for SPEEEEEEED
|
107
|
+
|
108
|
+
6.4.0
|
109
|
+
---------
|
110
|
+
|
111
|
+
- **SECURITY**: Validate input to avoid possible DoS in Web UI.
|
112
|
+
- Add **strict argument checking** [#5071]
|
113
|
+
Sidekiq will now log a warning if JSON-unsafe arguments are passed to `perform_async`.
|
114
|
+
Add `Sidekiq.strict_args!(false)` to your initializer to disable this warning.
|
115
|
+
This warning will switch to an exception in Sidekiq 7.0.
|
116
|
+
- Note that Delayed Extensions will be removed in Sidekiq 7.0 [#5076]
|
117
|
+
- Add `perform_{inline,sync}` in Sidekiq::Job to run a job synchronously [#5061, hasan-ally]
|
118
|
+
```ruby
|
119
|
+
SomeJob.perform_async(args...)
|
120
|
+
SomeJob.perform_sync(args...)
|
121
|
+
SomeJob.perform_inline(args...)
|
122
|
+
```
|
123
|
+
You can also dynamically redirect a job to run synchronously:
|
124
|
+
```ruby
|
125
|
+
SomeJob.set("sync": true).perform_async(args...) # will run via perform_inline
|
126
|
+
```
|
127
|
+
- Replace Sidekiq::Worker `app/workers` generator with Sidekiq::Job `app/sidekiq` generator [#5055]
|
128
|
+
```
|
129
|
+
bin/rails generate sidekiq:job ProcessOrderJob
|
130
|
+
```
|
131
|
+
- Fix job retries losing CurrentAttributes [#5090]
|
132
|
+
- Tweak shutdown to give long-running threads time to cleanup [#5095]
|
133
|
+
|
5
134
|
6.3.1
|
6
135
|
---------
|
7
136
|
|
@@ -285,6 +414,13 @@ See the [Logging wiki page](https://github.com/mperham/sidekiq/wiki/Logging) for
|
|
285
414
|
- Integrate the StandardRB code formatter to ensure consistent code
|
286
415
|
styling. [#4114, gearnode]
|
287
416
|
|
417
|
+
5.2.10
|
418
|
+
---------
|
419
|
+
|
420
|
+
- Backport fix for CVE-2022-23837.
|
421
|
+
- Migrate to `exists?` for redis-rb.
|
422
|
+
- Lock redis-rb to <4.6 to avoid deprecations.
|
423
|
+
|
288
424
|
5.2.9
|
289
425
|
---------
|
290
426
|
|
@@ -450,7 +586,7 @@ Sidekiq::Middleware::Server::Logging -> Sidekiq::JobLogger
|
|
450
586
|
- The `SomeWorker.set(options)` API was re-written to avoid thread-local state. [#2152]
|
451
587
|
- Sidekiq Enterprise's encrypted jobs now display "[encrypted data]" in the Web UI instead
|
452
588
|
of random hex bytes.
|
453
|
-
- Please see the [5.0 Upgrade notes](5.0-Upgrade.md) for more detail.
|
589
|
+
- Please see the [5.0 Upgrade notes](docs/5.0-Upgrade.md) for more detail.
|
454
590
|
|
455
591
|
4.2.10
|
456
592
|
-----------
|
@@ -668,7 +804,7 @@ Sidekiq::Queues.clear_all
|
|
668
804
|
- Sidekiq's internals have been completely overhauled for performance
|
669
805
|
and to remove dependencies. This has resulted in major speedups, as
|
670
806
|
[detailed on my blog](http://www.mikeperham.com/2015/10/14/optimizing-sidekiq/).
|
671
|
-
- See the [4.0 upgrade notes](4.0-Upgrade.md) for more detail.
|
807
|
+
- See the [4.0 upgrade notes](docs/4.0-Upgrade.md) for more detail.
|
672
808
|
|
673
809
|
3.5.4
|
674
810
|
-----------
|
@@ -935,7 +1071,7 @@ sidekiq_options :dead => false, :retry => 5
|
|
935
1071
|
3.0.0
|
936
1072
|
-----------
|
937
1073
|
|
938
|
-
Please see [3.0-Upgrade.md](3.0-Upgrade.md) for more comprehensive upgrade notes.
|
1074
|
+
Please see [3.0-Upgrade.md](docs/3.0-Upgrade.md) for more comprehensive upgrade notes.
|
939
1075
|
|
940
1076
|
- **Dead Job Queue** - jobs which run out of retries are now moved to a dead
|
941
1077
|
job queue. These jobs must be retried manually or they will expire
|
@@ -979,7 +1115,7 @@ Sidekiq::Client.via(ConnectionPool.new { Redis.new }) do
|
|
979
1115
|
end
|
980
1116
|
```
|
981
1117
|
**Sharding support does require a breaking change to client-side
|
982
|
-
middleware, see 3.0-Upgrade.md.**
|
1118
|
+
middleware, see docs/3.0-Upgrade.md.**
|
983
1119
|
- New Chinese, Greek, Swedish and Czech translations for the Web UI.
|
984
1120
|
- Updated most languages translations for the new UI features.
|
985
1121
|
- **Remove official Capistrano integration** - this integration has been
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
Copyright (c) Contributed Systems LLC
|
2
|
+
|
3
|
+
Sidekiq is an Open Source project licensed under the terms of
|
4
|
+
the LGPLv3 license. Please see <http://www.gnu.org/licenses/lgpl-3.0.html>
|
5
|
+
for license text.
|
6
|
+
|
7
|
+
Sidekiq Pro and Sidekiq Enterprise have a commercial-friendly license.
|
8
|
+
You can find the commercial license in COMM-LICENSE.txt.
|
9
|
+
Please see https://sidekiq.org for purchasing options.
|
data/README.md
CHANGED
@@ -27,23 +27,23 @@ This benchmark can be found in `bin/sidekiqload` and assumes a Redis network lat
|
|
27
27
|
Requirements
|
28
28
|
-----------------
|
29
29
|
|
30
|
-
- Redis:
|
31
|
-
- Ruby: MRI 2.
|
30
|
+
- Redis: 6.2+
|
31
|
+
- Ruby: MRI 2.7+ or JRuby 9.3+.
|
32
32
|
|
33
|
-
Sidekiq
|
33
|
+
Sidekiq 7.0 supports Rails 6.0+ but does not require it.
|
34
34
|
|
35
35
|
|
36
36
|
Installation
|
37
37
|
-----------------
|
38
38
|
|
39
|
-
|
39
|
+
bundle add sidekiq
|
40
40
|
|
41
41
|
|
42
42
|
Getting Started
|
43
43
|
-----------------
|
44
44
|
|
45
45
|
See the [Getting Started wiki page](https://github.com/mperham/sidekiq/wiki/Getting-Started) and follow the simple setup process.
|
46
|
-
You can watch [this
|
46
|
+
You can watch [this YouTube playlist](https://www.youtube.com/playlist?list=PLjeHh2LSCFrWGT5uVjUuFKAcrcj5kSai1) to learn all about
|
47
47
|
Sidekiq and see its features in action. Here's the Web UI:
|
48
48
|
|
49
49
|
![Web UI](https://github.com/mperham/sidekiq/raw/main/examples/web-ui.png)
|
@@ -52,24 +52,26 @@ Sidekiq and see its features in action. Here's the Web UI:
|
|
52
52
|
Want to Upgrade?
|
53
53
|
-------------------
|
54
54
|
|
55
|
+
Use `bundle up sidekiq` to upgrade Sidekiq and all its dependencies.
|
56
|
+
Upgrade notes between each major version can be found in the `docs/` directory.
|
57
|
+
|
55
58
|
I also sell Sidekiq Pro and Sidekiq Enterprise, extensions to Sidekiq which provide more
|
56
59
|
features, a commercial-friendly license and allow you to support high
|
57
60
|
quality open source development all at the same time. Please see the
|
58
61
|
[Sidekiq](https://sidekiq.org/) homepage for more detail.
|
59
62
|
|
60
|
-
Subscribe to the **[quarterly newsletter](https://tinyletter.com/sidekiq)** to stay informed about the latest
|
61
|
-
features and changes to Sidekiq and its bigger siblings.
|
62
|
-
|
63
63
|
|
64
64
|
Problems?
|
65
65
|
-----------------
|
66
66
|
|
67
|
-
**Please do not directly email any Sidekiq committers with questions or problems.**
|
67
|
+
**Please do not directly email any Sidekiq committers with questions or problems.**
|
68
|
+
A community is best served when discussions are held in public.
|
68
69
|
|
69
70
|
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.
|
70
71
|
Searching the [issues](https://github.com/mperham/sidekiq/issues) for your problem is also a good idea.
|
71
72
|
|
72
|
-
Sidekiq Pro and Sidekiq Enterprise customers get private email support.
|
73
|
+
Sidekiq Pro and Sidekiq Enterprise customers get private email support.
|
74
|
+
You can purchase at https://sidekiq.org; email support@contribsys.com for help.
|
73
75
|
|
74
76
|
Useful resources:
|
75
77
|
|
@@ -77,15 +79,19 @@ Useful resources:
|
|
77
79
|
* Occasional announcements are made to the [@sidekiq](https://twitter.com/sidekiq) Twitter account.
|
78
80
|
* The [Sidekiq tag](https://stackoverflow.com/questions/tagged/sidekiq) on Stack Overflow has lots of useful Q & A.
|
79
81
|
|
80
|
-
Every Friday morning is Sidekiq
|
82
|
+
Every Friday morning is Sidekiq office hour: I video chat and answer questions.
|
81
83
|
See the [Sidekiq support page](https://sidekiq.org/support.html) for details.
|
82
84
|
|
85
|
+
Contributing
|
86
|
+
-----------------
|
87
|
+
|
88
|
+
Please see [the contributing guidelines](https://github.com/mperham/sidekiq/blob/main/.github/contributing.md).
|
83
89
|
|
84
90
|
License
|
85
91
|
-----------------
|
86
92
|
|
87
|
-
Please see [LICENSE](https://github.com/mperham/sidekiq/blob/main/LICENSE) for licensing details.
|
88
|
-
|
93
|
+
Please see [LICENSE.txt](https://github.com/mperham/sidekiq/blob/main/LICENSE.txt) for licensing details.
|
94
|
+
The license for Sidekiq Pro and Sidekiq Enterprise can be found in [COMM-LICENSE.txt](https://github.com/mperham/sidekiq/blob/main/COMM-LICENSE.txt).
|
89
95
|
|
90
96
|
Author
|
91
97
|
-----------------
|
data/bin/sidekiq
CHANGED
@@ -4,13 +4,13 @@
|
|
4
4
|
# RUBYOPT=-w bundle exec sidekiq
|
5
5
|
$TESTING = false
|
6
6
|
|
7
|
-
require_relative
|
7
|
+
require_relative "../lib/sidekiq/cli"
|
8
8
|
|
9
9
|
def integrate_with_systemd
|
10
10
|
return unless ENV["NOTIFY_SOCKET"]
|
11
11
|
|
12
12
|
Sidekiq.configure_server do |config|
|
13
|
-
|
13
|
+
config.logger.info "Enabling systemd notification integration"
|
14
14
|
require "sidekiq/sd_notify"
|
15
15
|
config.on(:startup) do
|
16
16
|
Sidekiq::SdNotify.ready
|
@@ -31,12 +31,7 @@ begin
|
|
31
31
|
cli.run
|
32
32
|
rescue => e
|
33
33
|
raise e if $DEBUG
|
34
|
-
|
35
|
-
|
36
|
-
STDERR.puts e.backtrace.join("\n")
|
37
|
-
else
|
38
|
-
cli.handle_exception e
|
39
|
-
end
|
40
|
-
|
34
|
+
warn e.message
|
35
|
+
warn e.backtrace.join("\n")
|
41
36
|
exit 1
|
42
37
|
end
|
data/bin/sidekiqload
CHANGED
@@ -4,78 +4,71 @@
|
|
4
4
|
# RUBYOPT=-w bundle exec sidekiq
|
5
5
|
$TESTING = false
|
6
6
|
|
7
|
-
#require
|
8
|
-
require
|
7
|
+
# require "ruby-prof"
|
8
|
+
require "bundler/setup"
|
9
9
|
Bundler.require(:default, :load_test)
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
Sidekiq.configure_server do |config|
|
17
|
-
config.options[:concurrency] = 10
|
18
|
-
config.redis = { db: 13, port: 6380, driver: :hiredis }
|
19
|
-
config.options[:queues] << 'default'
|
11
|
+
x = Sidekiq.configure_embed do |config|
|
12
|
+
config.redis = {db: 13, port: 6380}
|
13
|
+
config.concurrency = 10
|
14
|
+
# config.redis = { db: 13, port: 6380, driver: :hiredis}
|
15
|
+
config.queues = %w[default]
|
20
16
|
config.logger.level = Logger::ERROR
|
21
17
|
config.average_scheduled_poll_interval = 2
|
22
18
|
config.reliable! if defined?(Sidekiq::Pro)
|
23
19
|
end
|
24
20
|
|
25
21
|
class LoadWorker
|
26
|
-
include Sidekiq::
|
22
|
+
include Sidekiq::Job
|
27
23
|
sidekiq_options retry: 1
|
28
24
|
sidekiq_retry_in do |x|
|
29
25
|
1
|
30
26
|
end
|
31
27
|
|
32
|
-
def perform(idx, ts=nil)
|
33
|
-
puts(Time.now.to_f - ts) if ts
|
34
|
-
#raise idx.to_s if idx % 100 == 1
|
28
|
+
def perform(idx, ts = nil)
|
29
|
+
puts(Time.now.to_f - ts) if !ts.nil?
|
30
|
+
# raise idx.to_s if idx % 100 == 1
|
35
31
|
end
|
36
32
|
end
|
37
33
|
|
38
34
|
# brew tap shopify/shopify
|
39
35
|
# brew install toxiproxy
|
40
|
-
# gem install toxiproxy
|
41
36
|
# run `toxiproxy-server` in a separate terminal window.
|
42
|
-
require
|
37
|
+
require "toxiproxy"
|
43
38
|
# simulate a non-localhost network for realer-world conditions.
|
44
39
|
# adding 1ms of network latency has an ENORMOUS impact on benchmarks
|
45
40
|
Toxiproxy.populate([{
|
46
|
-
|
47
|
-
|
48
|
-
|
41
|
+
name: "redis",
|
42
|
+
listen: "127.0.0.1:6380",
|
43
|
+
upstream: "127.0.0.1:6379"
|
49
44
|
}])
|
50
45
|
|
51
46
|
self_read, self_write = IO.pipe
|
52
|
-
%w
|
53
|
-
|
54
|
-
|
55
|
-
self_write.puts(sig)
|
56
|
-
end
|
57
|
-
rescue ArgumentError
|
58
|
-
puts "Signal #{sig} not supported"
|
47
|
+
%w[INT TERM TSTP TTIN].each do |sig|
|
48
|
+
trap sig do
|
49
|
+
self_write.puts(sig)
|
59
50
|
end
|
51
|
+
rescue ArgumentError
|
52
|
+
puts "Signal #{sig} not supported"
|
60
53
|
end
|
61
54
|
|
62
|
-
Sidekiq.redis {|c| c.flushdb}
|
55
|
+
Sidekiq.redis { |c| c.flushdb }
|
63
56
|
def handle_signal(launcher, sig)
|
64
57
|
Sidekiq.logger.debug "Got #{sig} signal"
|
65
58
|
case sig
|
66
|
-
when
|
59
|
+
when "INT"
|
67
60
|
# Handle Ctrl-C in JRuby like MRI
|
68
61
|
# http://jira.codehaus.org/browse/JRUBY-4637
|
69
62
|
raise Interrupt
|
70
|
-
when
|
63
|
+
when "TERM"
|
71
64
|
# Heroku sends TERM and then waits 30 seconds for process to exit.
|
72
65
|
raise Interrupt
|
73
|
-
when
|
66
|
+
when "TSTP"
|
74
67
|
Sidekiq.logger.info "Received TSTP, no longer accepting new work"
|
75
68
|
launcher.quiet
|
76
|
-
when
|
69
|
+
when "TTIN"
|
77
70
|
Thread.list.each do |thread|
|
78
|
-
Sidekiq.logger.warn "Thread TID-#{(thread.object_id ^ ::Process.pid).to_s(36)} #{thread[
|
71
|
+
Sidekiq.logger.warn "Thread TID-#{(thread.object_id ^ ::Process.pid).to_s(36)} #{thread["label"]}"
|
79
72
|
if thread.backtrace
|
80
73
|
Sidekiq.logger.warn thread.backtrace.join("\n")
|
81
74
|
else
|
@@ -93,65 +86,67 @@ iter = 10
|
|
93
86
|
count = 10_000
|
94
87
|
|
95
88
|
iter.times do
|
96
|
-
arr = Array.new(count)
|
97
|
-
|
98
|
-
end
|
99
|
-
count.times do |idx|
|
100
|
-
arr[idx][0] = idx
|
101
|
-
end
|
102
|
-
Sidekiq::Client.push_bulk('class' => LoadWorker, 'args' => arr)
|
89
|
+
arr = Array.new(count) { |idx| [idx] }
|
90
|
+
Sidekiq::Client.push_bulk("class" => LoadWorker, "args" => arr)
|
103
91
|
end
|
104
|
-
Sidekiq.logger.error "Created #{count*iter} jobs"
|
92
|
+
Sidekiq.logger.error "Created #{count * iter} jobs"
|
105
93
|
|
106
94
|
start = Time.now
|
107
95
|
|
108
96
|
Monitoring = Thread.new do
|
109
|
-
|
110
|
-
|
97
|
+
loop do
|
98
|
+
sleep 1.0
|
99
|
+
qsize = Sidekiq.redis do |conn|
|
100
|
+
conn.llen "queue:default"
|
101
|
+
end
|
102
|
+
total = qsize
|
103
|
+
# Sidekiq.logger.error("RSS: #{Process.rss} Pending: #{total}")
|
104
|
+
if total == 0
|
105
|
+
Sidekiq.logger.error("Done, #{iter * count} jobs in #{Time.now - start} sec")
|
106
|
+
Sidekiq.logger.error("Now here's the latency for three jobs")
|
107
|
+
|
108
|
+
LoadWorker.perform_async(1, Time.now.to_f)
|
109
|
+
LoadWorker.perform_async(2, Time.now.to_f)
|
110
|
+
LoadWorker.perform_async(3, Time.now.to_f)
|
111
|
+
|
111
112
|
sleep 0.2
|
112
|
-
|
113
|
-
conn.llen "queue:default"
|
114
|
-
end
|
115
|
-
total = qsize
|
116
|
-
#Sidekiq.logger.error("RSS: #{Process.rss} Pending: #{total}")
|
117
|
-
if total == 0
|
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
|
126
|
-
exit(0)
|
127
|
-
end
|
113
|
+
exit(0)
|
128
114
|
end
|
129
115
|
end
|
130
116
|
end
|
131
117
|
|
118
|
+
def with_latency(latency, &block)
|
119
|
+
Sidekiq.logger.error "Simulating #{latency}ms of latency between Sidekiq and redis"
|
120
|
+
if latency > 0
|
121
|
+
Toxiproxy[:redis].downstream(:latency, latency: latency).apply(&block)
|
122
|
+
else
|
123
|
+
yield
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
132
127
|
begin
|
133
|
-
#RubyProf
|
134
|
-
#RubyProf.start
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
while readable_io = IO.select([self_read])
|
128
|
+
# RubyProf.exclude_threads = [Monitoring]
|
129
|
+
# RubyProf.start
|
130
|
+
|
131
|
+
with_latency(Integer(ENV.fetch("LATENCY", "1"))) do
|
132
|
+
x.run
|
133
|
+
|
134
|
+
while (readable_io = IO.select([self_read]))
|
142
135
|
signal = readable_io.first[0].gets.strip
|
143
|
-
handle_signal(
|
136
|
+
handle_signal(x, signal)
|
144
137
|
end
|
145
138
|
end
|
146
|
-
rescue SystemExit
|
147
|
-
#Sidekiq.logger.error("Profiling...")
|
148
|
-
#result = RubyProf.stop
|
149
|
-
#printer = RubyProf::GraphHtmlPrinter.new(result)
|
150
|
-
#printer.print(File.new("output.html", "w"), :
|
139
|
+
rescue SystemExit
|
140
|
+
# Sidekiq.logger.error("Profiling...")
|
141
|
+
# result = RubyProf.stop
|
142
|
+
# printer = RubyProf::GraphHtmlPrinter.new(result)
|
143
|
+
# printer.print(File.new("output.html", "w"), min_percent: 1)
|
151
144
|
# normal
|
152
145
|
rescue => e
|
153
146
|
raise e if $DEBUG
|
154
|
-
|
155
|
-
|
147
|
+
warn e.message
|
148
|
+
warn e.backtrace.join("\n")
|
156
149
|
exit 1
|
150
|
+
ensure
|
151
|
+
x.stop
|
157
152
|
end
|
data/bin/sidekiqmon
CHANGED
@@ -0,0 +1,57 @@
|
|
1
|
+
require "rails/generators/named_base"
|
2
|
+
|
3
|
+
module Sidekiq
|
4
|
+
module Generators # :nodoc:
|
5
|
+
class JobGenerator < ::Rails::Generators::NamedBase # :nodoc:
|
6
|
+
desc "This generator creates a Sidekiq Job in app/sidekiq and a corresponding test"
|
7
|
+
|
8
|
+
check_class_collision suffix: "Job"
|
9
|
+
|
10
|
+
def self.default_generator_root
|
11
|
+
File.dirname(__FILE__)
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_job_file
|
15
|
+
template "job.rb.erb", File.join("app/sidekiq", class_path, "#{file_name}_job.rb")
|
16
|
+
end
|
17
|
+
|
18
|
+
def create_test_file
|
19
|
+
return unless test_framework
|
20
|
+
|
21
|
+
if test_framework == :rspec
|
22
|
+
create_job_spec
|
23
|
+
else
|
24
|
+
create_job_test
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def create_job_spec
|
31
|
+
template_file = File.join(
|
32
|
+
"spec/sidekiq",
|
33
|
+
class_path,
|
34
|
+
"#{file_name}_job_spec.rb"
|
35
|
+
)
|
36
|
+
template "job_spec.rb.erb", template_file
|
37
|
+
end
|
38
|
+
|
39
|
+
def create_job_test
|
40
|
+
template_file = File.join(
|
41
|
+
"test/sidekiq",
|
42
|
+
class_path,
|
43
|
+
"#{file_name}_job_test.rb"
|
44
|
+
)
|
45
|
+
template "job_test.rb.erb", template_file
|
46
|
+
end
|
47
|
+
|
48
|
+
def file_name
|
49
|
+
@_file_name ||= super.sub(/_?job\z/i, "")
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_framework
|
53
|
+
::Rails.application.config.generators.options[:rails][:test_framework]
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|