sidekiq 4.2.4 → 5.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.
- checksums.yaml +5 -5
- data/.circleci/config.yml +61 -0
- data/.github/issue_template.md +8 -1
- data/.gitignore +3 -0
- data/.travis.yml +5 -6
- data/5.0-Upgrade.md +56 -0
- data/COMM-LICENSE +12 -10
- data/Changes.md +220 -0
- data/Ent-Changes.md +94 -2
- data/Gemfile +12 -22
- data/LICENSE +1 -1
- data/Pro-4.0-Upgrade.md +35 -0
- data/Pro-Changes.md +176 -2
- data/README.md +10 -7
- data/Rakefile +3 -3
- data/bin/sidekiqctl +13 -92
- data/bin/sidekiqload +16 -34
- data/lib/generators/sidekiq/templates/worker_spec.rb.erb +1 -1
- data/lib/generators/sidekiq/templates/worker_test.rb.erb +1 -1
- data/lib/sidekiq/api.rb +166 -68
- data/lib/sidekiq/cli.rb +122 -77
- data/lib/sidekiq/client.rb +25 -18
- data/lib/sidekiq/core_ext.rb +1 -106
- data/lib/sidekiq/ctl.rb +221 -0
- data/lib/sidekiq/delay.rb +42 -0
- data/lib/sidekiq/exception_handler.rb +2 -4
- data/lib/sidekiq/extensions/generic_proxy.rb +7 -1
- data/lib/sidekiq/fetch.rb +1 -1
- data/lib/sidekiq/job_logger.rb +25 -0
- data/lib/sidekiq/job_retry.rb +262 -0
- data/lib/sidekiq/launcher.rb +49 -40
- data/lib/sidekiq/logging.rb +18 -2
- data/lib/sidekiq/manager.rb +6 -7
- data/lib/sidekiq/middleware/server/active_record.rb +10 -0
- data/lib/sidekiq/processor.rb +127 -37
- data/lib/sidekiq/rails.rb +16 -51
- data/lib/sidekiq/redis_connection.rb +50 -5
- data/lib/sidekiq/scheduled.rb +35 -8
- data/lib/sidekiq/testing.rb +24 -7
- data/lib/sidekiq/util.rb +6 -2
- data/lib/sidekiq/version.rb +1 -1
- data/lib/sidekiq/web/action.rb +3 -7
- data/lib/sidekiq/web/application.rb +38 -22
- data/lib/sidekiq/web/helpers.rb +78 -27
- data/lib/sidekiq/web/router.rb +14 -10
- data/lib/sidekiq/web.rb +4 -4
- data/lib/sidekiq/worker.rb +118 -19
- data/lib/sidekiq.rb +27 -26
- data/sidekiq.gemspec +8 -13
- data/web/assets/javascripts/application.js +0 -0
- data/web/assets/javascripts/dashboard.js +33 -18
- data/web/assets/stylesheets/application-rtl.css +246 -0
- data/web/assets/stylesheets/application.css +371 -6
- data/web/assets/stylesheets/bootstrap-rtl.min.css +9 -0
- data/web/assets/stylesheets/bootstrap.css +2 -2
- data/web/locales/ar.yml +81 -0
- data/web/locales/en.yml +2 -0
- data/web/locales/es.yml +4 -3
- data/web/locales/fa.yml +80 -0
- data/web/locales/he.yml +79 -0
- data/web/locales/ja.yml +5 -3
- data/web/locales/ur.yml +80 -0
- data/web/views/_footer.erb +5 -2
- data/web/views/_job_info.erb +1 -1
- data/web/views/_nav.erb +4 -18
- data/web/views/_paging.erb +1 -1
- data/web/views/busy.erb +9 -5
- data/web/views/dashboard.erb +3 -3
- data/web/views/layout.erb +11 -2
- data/web/views/morgue.erb +14 -10
- data/web/views/queue.erb +11 -10
- data/web/views/queues.erb +4 -2
- data/web/views/retries.erb +17 -11
- data/web/views/retry.erb +1 -1
- data/web/views/scheduled.erb +2 -2
- metadata +32 -151
- data/lib/sidekiq/middleware/server/logging.rb +0 -40
- data/lib/sidekiq/middleware/server/retry_jobs.rb +0 -205
- data/test/config.yml +0 -9
- data/test/env_based_config.yml +0 -11
- data/test/fake_env.rb +0 -1
- data/test/fixtures/en.yml +0 -2
- data/test/helper.rb +0 -75
- data/test/test_actors.rb +0 -138
- data/test/test_api.rb +0 -528
- data/test/test_cli.rb +0 -418
- data/test/test_client.rb +0 -266
- data/test/test_exception_handler.rb +0 -56
- data/test/test_extensions.rb +0 -127
- data/test/test_fetch.rb +0 -50
- data/test/test_launcher.rb +0 -95
- data/test/test_logging.rb +0 -35
- data/test/test_manager.rb +0 -50
- data/test/test_middleware.rb +0 -158
- data/test/test_processor.rb +0 -235
- data/test/test_rails.rb +0 -22
- data/test/test_redis_connection.rb +0 -132
- data/test/test_retry.rb +0 -326
- data/test/test_retry_exhausted.rb +0 -149
- data/test/test_scheduled.rb +0 -115
- data/test/test_scheduling.rb +0 -58
- data/test/test_sidekiq.rb +0 -107
- data/test/test_testing.rb +0 -143
- data/test/test_testing_fake.rb +0 -357
- data/test/test_testing_inline.rb +0 -94
- data/test/test_util.rb +0 -13
- data/test/test_web.rb +0 -726
- data/test/test_web_helpers.rb +0 -54
data/Pro-4.0-Upgrade.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Welcome to Sidekiq Pro 4.0!
|
2
|
+
|
3
|
+
Sidekiq Pro 4.0 is designed to work with Sidekiq 5.0.
|
4
|
+
|
5
|
+
## What's New
|
6
|
+
|
7
|
+
* Batches now "die" if any of their jobs die. You can enumerate the set
|
8
|
+
of dead batches and their associated dead jobs. The success callback
|
9
|
+
for a dead batch will never fire unless these jobs are fixed.
|
10
|
+
```ruby
|
11
|
+
Sidekiq::Batch::DeadSet.new.each do |status|
|
12
|
+
status.dead? # => true
|
13
|
+
status.dead_jobs # => [...]
|
14
|
+
end
|
15
|
+
```
|
16
|
+
This API allows you to enumerate the batches which need help.
|
17
|
+
If you fix the issue and the dead jobs succeed, the batch will succeed.
|
18
|
+
* The older `reliable_fetch` and `timed_fetch` algorithms have been
|
19
|
+
removed. Only super\_fetch is available in 4.0.
|
20
|
+
* The statsd middleware has been tweaked to remove support for legacy,
|
21
|
+
pre-3.6.0 configuration and add relevant tags.
|
22
|
+
* Requires Sidekiq 5.0.5+.
|
23
|
+
|
24
|
+
## Upgrade
|
25
|
+
|
26
|
+
* Upgrade to the latest Sidekiq Pro 3.x.
|
27
|
+
```ruby
|
28
|
+
gem 'sidekiq-pro', '< 4'
|
29
|
+
```
|
30
|
+
* Fix any deprecation warnings you see.
|
31
|
+
* Upgrade to 4.x.
|
32
|
+
```ruby
|
33
|
+
gem 'sidekiq-pro', '< 5'
|
34
|
+
```
|
35
|
+
|
data/Pro-Changes.md
CHANGED
@@ -1,8 +1,182 @@
|
|
1
|
-
Sidekiq Pro Changelog
|
2
|
-
|
1
|
+
# Sidekiq Pro Changelog
|
2
|
+
|
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)
|
3
4
|
|
4
5
|
Please see [http://sidekiq.org/](http://sidekiq.org/) for more details and how to buy.
|
5
6
|
|
7
|
+
HEAD
|
8
|
+
---------
|
9
|
+
|
10
|
+
- Add ES translations, see issues [#3949](https://github.com/mperham/sidekiq/issues/3949) and [#3951](https://github.com/mperham/sidekiq/issues/3951) to add your own language.
|
11
|
+
|
12
|
+
4.0.5
|
13
|
+
---------
|
14
|
+
|
15
|
+
- Increase super\_fetch retriever thread count from 1 to 2 to make it
|
16
|
+
less sensitive to Redis latency.
|
17
|
+
- Better handling of invalid job JSON by reliable scheduler [#4053]
|
18
|
+
- Added ZH, PT, JA and RU translations.
|
19
|
+
|
20
|
+
4.0.4
|
21
|
+
---------
|
22
|
+
|
23
|
+
- Update Sidekiq::Client patches to work with new Module#prepend
|
24
|
+
mechanism in Sidekiq 5.2.0. [#3930]
|
25
|
+
|
26
|
+
4.0.3
|
27
|
+
---------
|
28
|
+
|
29
|
+
- Add at\_exit handler to push any saved jobs in `reliable_push` when exiting. [#3823]
|
30
|
+
- Implement batch death callback. This is fired the first time a job within a batch dies. [#3841]
|
31
|
+
```ruby
|
32
|
+
batch = Sidekiq::Batch.new
|
33
|
+
batch.on(:death, ...)
|
34
|
+
```
|
35
|
+
|
36
|
+
4.0.2
|
37
|
+
---------
|
38
|
+
|
39
|
+
- Remove super\_fetch edge case leading to an unnecessary `sleep(1)`
|
40
|
+
call and resulting latency [#3790]
|
41
|
+
- Fix possible bad statsd metric call on super\_fetch startup
|
42
|
+
- Remove superfluous `freeze` calls on Strings [#3759]
|
43
|
+
|
44
|
+
4.0.1
|
45
|
+
---------
|
46
|
+
|
47
|
+
- Fix incompatibility with the statsd-ruby gem [#3740]
|
48
|
+
- Add tags to Statsd metrics when using Datadog [#3744]
|
49
|
+
|
50
|
+
4.0.0
|
51
|
+
---------
|
52
|
+
|
53
|
+
- See the [Sidekiq Pro 4.0](Pro-4.0-Upgrade.md) release notes.
|
54
|
+
|
55
|
+
|
56
|
+
3.7.1
|
57
|
+
---------
|
58
|
+
|
59
|
+
- Deprecate timed\_fetch. Switch to super\_fetch:
|
60
|
+
```ruby
|
61
|
+
config.super_fetch!
|
62
|
+
```
|
63
|
+
|
64
|
+
|
65
|
+
3.7.0
|
66
|
+
---------
|
67
|
+
|
68
|
+
- Refactor batch job success/failure to gracefully handle several edge
|
69
|
+
cases with regard to Sidekiq::Shutdown. This should greatly reduce
|
70
|
+
the chances of seeing the long-standing "negative pending count" problem. [#3710]
|
71
|
+
|
72
|
+
|
73
|
+
3.6.1
|
74
|
+
---------
|
75
|
+
|
76
|
+
- Add support for Datadog::Statsd, it is the recommended Statsd client. [#3699]
|
77
|
+
```ruby
|
78
|
+
Sidekiq::Pro.dogstatsd = ->{ Datadog::Statsd.new("metrics.example.com", 8125) }
|
79
|
+
```
|
80
|
+
- Size the statsd connection pool based on Sidekiq's concurrency [#3700]
|
81
|
+
|
82
|
+
|
83
|
+
3.6.0
|
84
|
+
---------
|
85
|
+
|
86
|
+
This release overhauls the Statsd metrics support and adds more
|
87
|
+
metrics for tracking Pro feature usage. In your initializer:
|
88
|
+
```ruby
|
89
|
+
Sidekiq::Pro.statsd = ->{ ::Statsd.new("127.0.0.1", 8125) }
|
90
|
+
```
|
91
|
+
Sidekiq Pro will emit more metrics to Statsd:
|
92
|
+
```
|
93
|
+
jobs.expired - when a job is expired
|
94
|
+
jobs.recovered.push - when a job is recovered by reliable_push after network outage
|
95
|
+
jobs.recovered.fetch - when a job is recovered by super_fetch after process crash
|
96
|
+
batch.created - when a batch is created
|
97
|
+
batch.complete - when a batch is completed
|
98
|
+
batch.success - when a batch is successful
|
99
|
+
```
|
100
|
+
Sidekiq Pro's existing Statsd middleware has been rewritten to leverage the new API.
|
101
|
+
Everything should be backwards compatible with one deprecation notice.
|
102
|
+
|
103
|
+
|
104
|
+
3.5.4
|
105
|
+
---------
|
106
|
+
|
107
|
+
- Fix case in SuperFetch where Redis downtime can lead to processor thread death [#3684]
|
108
|
+
- Fix case where TimedFetch might not recover some pending jobs
|
109
|
+
- Fix edge case in Batch::Status#poll leading to premature completion [#3640]
|
110
|
+
- Adjust scan API to check 100 elements at a time, to minimize network round trips
|
111
|
+
when scanning large sets.
|
112
|
+
|
113
|
+
3.5.3
|
114
|
+
---------
|
115
|
+
|
116
|
+
- Restore error check for super\_fetch's job ack [#3601]
|
117
|
+
- Trim error messages saved in Batch's failure hash, preventing huge
|
118
|
+
messages from bloating Redis. [#3570]
|
119
|
+
|
120
|
+
3.5.2
|
121
|
+
---------
|
122
|
+
|
123
|
+
- Fix `Status#completed?` when run against a Batch that had succeeded
|
124
|
+
and was deleted. [#3519]
|
125
|
+
|
126
|
+
3.5.1
|
127
|
+
---------
|
128
|
+
|
129
|
+
- Work with Sidekiq 5.0.2+
|
130
|
+
- Improve performance of super\_fetch with weighted queues [#3489]
|
131
|
+
|
132
|
+
3.5.0
|
133
|
+
---------
|
134
|
+
|
135
|
+
- Add queue pause/unpause endpoints for scripting via curl [#3445]
|
136
|
+
- Change how super\_fetch names private queues to avoid hostname/queue clashes. [#3443]
|
137
|
+
- Re-implement `Sidekiq::Queue#delete_job` to avoid O(n) runtime [#3408]
|
138
|
+
- Batch page displays Pending JIDs if less than 10 [#3130]
|
139
|
+
- Batch page has a Search button to find associated Retries [#3130]
|
140
|
+
- Make Batch UI progress bar more friendly to the colorblind [#3387]
|
141
|
+
|
142
|
+
3.4.5
|
143
|
+
---------
|
144
|
+
|
145
|
+
- Fix potential job loss with reliable scheduler when lots of jobs are scheduled
|
146
|
+
at precisely the same time. Thanks to raivil for his hard work in
|
147
|
+
reproducing the bug. [#3371]
|
148
|
+
|
149
|
+
3.4.4
|
150
|
+
---------
|
151
|
+
|
152
|
+
- Optimize super\_fetch shutdown to restart jobs quicker [#3249]
|
153
|
+
|
154
|
+
3.4.3
|
155
|
+
---------
|
156
|
+
|
157
|
+
- Limit reliable scheduler to enqueue up to 100 jobs per call, minimizing Redis latency [#3332]
|
158
|
+
- Fix bug in super\_fetch logic for queues with `_` in the name [#3339]
|
159
|
+
|
160
|
+
3.4.2
|
161
|
+
---------
|
162
|
+
|
163
|
+
- Add `Batch::Status#invalidated?` API which returns true if any/all
|
164
|
+
JIDs were invalidated within the batch. [#3326]
|
165
|
+
|
166
|
+
3.4.1
|
167
|
+
---------
|
168
|
+
|
169
|
+
- Allow super\_fetch's orphan job check to happen as often as every hour [#3273]
|
170
|
+
- Officially deprecate reliable\_fetch algorithm, I now recommend you use `super_fetch` instead:
|
171
|
+
```ruby
|
172
|
+
Sidekiq.configure_server do |config|
|
173
|
+
config.super_fetch!
|
174
|
+
end
|
175
|
+
```
|
176
|
+
Also note that Sidekiq's `-i/--index` option is no longer used/relevant with super\_fetch.
|
177
|
+
- Don't display "Delete/Retry All" buttons when filtering in Web UI [#3243]
|
178
|
+
- Reimplement Sidekiq::JobSet#find\_job with ZSCAN [#3197]
|
179
|
+
|
6
180
|
3.4.0
|
7
181
|
---------
|
8
182
|
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@ Sidekiq
|
|
3
3
|
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/sidekiq.svg)](https://rubygems.org/gems/sidekiq)
|
5
5
|
[![Code Climate](https://codeclimate.com/github/mperham/sidekiq.svg)](https://codeclimate.com/github/mperham/sidekiq)
|
6
|
-
[![Build Status](https://
|
6
|
+
[![Build Status](https://circleci.com/gh/mperham/sidekiq/tree/master.svg?style=svg)](https://circleci.com/gh/mperham/sidekiq/tree/master)
|
7
7
|
[![Gitter Chat](https://badges.gitter.im/mperham/sidekiq.svg)](https://gitter.im/mperham/sidekiq)
|
8
8
|
|
9
9
|
|
@@ -28,13 +28,14 @@ Sidekiq 3.5.1 | 22ms | 1257 MB | 125 sec | 800 jobs/sec
|
|
28
28
|
Resque 1.25.2 | - | - | 420 sec | 240 jobs/sec
|
29
29
|
DelayedJob 4.1.1 | - | - | 465 sec | 215 jobs/sec
|
30
30
|
|
31
|
+
<small>This benchmark can be found in `bin/sidekiqload`.</small>
|
31
32
|
|
32
33
|
Requirements
|
33
34
|
-----------------
|
34
35
|
|
35
|
-
Sidekiq supports CRuby 2.
|
36
|
+
Sidekiq supports CRuby 2.2.2+ and JRuby 9k.
|
36
37
|
|
37
|
-
All Rails releases >=
|
38
|
+
All Rails releases >= 4.0 are officially supported.
|
38
39
|
|
39
40
|
Redis 2.8 or greater is required. 3.0.3+ is recommended for large
|
40
41
|
installations with thousands of worker threads.
|
@@ -50,7 +51,8 @@ Getting Started
|
|
50
51
|
-----------------
|
51
52
|
|
52
53
|
See the [Getting Started wiki page](https://github.com/mperham/sidekiq/wiki/Getting-Started) and follow the simple setup process.
|
53
|
-
You can watch [
|
54
|
+
You can watch [this Youtube playlist](https://www.youtube.com/playlist?list=PLjeHh2LSCFrWGT5uVjUuFKAcrcj5kSai1) to learn all about
|
55
|
+
Sidekiq and see its features in action. Here's the Web UI:
|
54
56
|
|
55
57
|
![Web UI](https://github.com/mperham/sidekiq/raw/master/examples/web-ui.png)
|
56
58
|
|
@@ -75,17 +77,18 @@ Problems?
|
|
75
77
|
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.
|
76
78
|
Searching the [issues](https://github.com/mperham/sidekiq/issues) for your problem is also a good idea.
|
77
79
|
|
80
|
+
Sidekiq Pro and Sidekiq Enterprise customers get private email support. You can purchase at http://sidekiq.org; email support@contribsys.com for help.
|
81
|
+
|
78
82
|
Useful resources:
|
79
83
|
|
80
84
|
* Product documentation is in the [wiki](https://github.com/mperham/sidekiq/wiki).
|
81
85
|
* Release announcements are made to the [@sidekiq](https://twitter.com/sidekiq) Twitter account.
|
82
|
-
* Here's a [Reddit forum](https://reddit.com/r/sidekiq) dedicated to Sidekiq discussion
|
83
86
|
* The [Sidekiq tag](https://stackoverflow.com/questions/tagged/sidekiq) on Stack Overflow has lots of useful Q & A.
|
84
87
|
|
85
|
-
**No support via Twitter
|
88
|
+
**No support via Twitter**
|
86
89
|
|
87
90
|
Every Friday morning is Sidekiq happy hour: I video chat and answer questions.
|
88
|
-
See the [Sidekiq support page](http://sidekiq.org/support) for details.
|
91
|
+
See the [Sidekiq support page](http://sidekiq.org/support.html) for details.
|
89
92
|
|
90
93
|
Thanks
|
91
94
|
-----------------
|
data/Rakefile
CHANGED
data/bin/sidekiqctl
CHANGED
@@ -1,99 +1,20 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'fileutils'
|
4
|
+
require 'sidekiq/api'
|
5
|
+
require 'sidekiq/ctl'
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
attr_reader :stage, :pidfile, :kill_timeout
|
9
|
-
|
10
|
-
def self.print_usage
|
11
|
-
puts "#{File.basename($0)} - stop a Sidekiq process from the command line."
|
12
|
-
puts
|
13
|
-
puts "Usage: #{File.basename($0)} <command> <pidfile> <kill_timeout>"
|
14
|
-
puts " where <command> is either 'quiet' or 'stop'"
|
15
|
-
puts " <pidfile> is path to a pidfile"
|
16
|
-
puts " <kill_timeout> is number of seconds to wait until Sidekiq exits"
|
17
|
-
puts " (default: #{Sidekiqctl::DEFAULT_KILL_TIMEOUT}), after which Sidekiq will be KILL'd"
|
18
|
-
puts
|
19
|
-
puts "Be sure to set the kill_timeout LONGER than Sidekiq's -t timeout. If you want"
|
20
|
-
puts "to wait 60 seconds for jobs to finish, use `sidekiq -t 60` and `sidekiqctl stop"
|
21
|
-
puts " path_to_pidfile 61`"
|
22
|
-
puts
|
23
|
-
end
|
24
|
-
|
25
|
-
def initialize(stage, pidfile, timeout)
|
26
|
-
@stage = stage
|
27
|
-
@pidfile = pidfile
|
28
|
-
@kill_timeout = timeout
|
29
|
-
|
30
|
-
done('No pidfile given', :error) if !pidfile
|
31
|
-
done("Pidfile #{pidfile} does not exist", :warn) if !File.exist?(pidfile)
|
32
|
-
done('Invalid pidfile content', :error) if pid == 0
|
33
|
-
|
34
|
-
fetch_process
|
35
|
-
|
36
|
-
begin
|
37
|
-
send(stage)
|
38
|
-
rescue NoMethodError
|
39
|
-
done "Invalid command: #{stage}", :error
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def fetch_process
|
44
|
-
Process.kill(0, pid)
|
45
|
-
rescue Errno::ESRCH
|
46
|
-
done "Process doesn't exist", :error
|
47
|
-
# We were not allowed to send a signal, but the process must have existed
|
48
|
-
# when Process.kill() was called.
|
49
|
-
rescue Errno::EPERM
|
50
|
-
return pid
|
51
|
-
end
|
52
|
-
|
53
|
-
def done(msg, error = nil)
|
54
|
-
puts msg
|
55
|
-
exit(exit_signal(error))
|
56
|
-
end
|
57
|
-
|
58
|
-
def exit_signal(error)
|
59
|
-
(error == :error) ? 1 : 0
|
60
|
-
end
|
61
|
-
|
62
|
-
def pid
|
63
|
-
@pid ||= File.read(pidfile).to_i
|
64
|
-
end
|
65
|
-
|
66
|
-
def quiet
|
67
|
-
`kill -USR1 #{pid}`
|
68
|
-
end
|
69
|
-
|
70
|
-
def stop
|
71
|
-
`kill -TERM #{pid}`
|
72
|
-
kill_timeout.times do
|
73
|
-
begin
|
74
|
-
Process.kill(0, pid)
|
75
|
-
rescue Errno::ESRCH
|
76
|
-
FileUtils.rm_f pidfile
|
77
|
-
done 'Sidekiq shut down gracefully.'
|
78
|
-
rescue Errno::EPERM
|
79
|
-
done 'Not permitted to shut down Sidekiq.'
|
80
|
-
end
|
81
|
-
sleep 1
|
82
|
-
end
|
83
|
-
`kill -9 #{pid}`
|
84
|
-
FileUtils.rm_f pidfile
|
85
|
-
done 'Sidekiq shut down forcefully.'
|
86
|
-
end
|
87
|
-
alias_method :shutdown, :stop
|
88
|
-
end
|
89
|
-
|
90
|
-
if ARGV.length < 2
|
91
|
-
Sidekiqctl.print_usage
|
7
|
+
if ARGV[0] == 'status'
|
8
|
+
Sidekiq::Ctl::Status.new.display(ARGV[1])
|
92
9
|
else
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
10
|
+
if ARGV.length < 2
|
11
|
+
Sidekiq::Ctl.print_usage
|
12
|
+
else
|
13
|
+
stage = ARGV[0]
|
14
|
+
pidfile = ARGV[1]
|
15
|
+
timeout = ARGV[2].to_i
|
16
|
+
timeout = Sidekiq::Ctl::DEFAULT_KILL_TIMEOUT if timeout == 0
|
97
17
|
|
98
|
-
|
18
|
+
Sidekiq::Ctl.new(stage, pidfile, timeout)
|
19
|
+
end
|
99
20
|
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 = {
|
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,17 +36,17 @@ 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
|
-
%w(INT TERM
|
49
|
+
%w(INT TERM TSTP TTIN).each do |sig|
|
63
50
|
begin
|
64
51
|
trap sig do
|
65
52
|
self_write.puts(sig)
|
@@ -78,19 +65,14 @@ def handle_signal(launcher, sig)
|
|
78
65
|
# http://jira.codehaus.org/browse/JRUBY-4637
|
79
66
|
raise Interrupt
|
80
67
|
when 'TERM'
|
81
|
-
# Heroku sends TERM and then waits
|
68
|
+
# Heroku sends TERM and then waits 30 seconds for process to exit.
|
82
69
|
raise Interrupt
|
83
|
-
when '
|
84
|
-
Sidekiq.logger.info "Received
|
70
|
+
when 'TSTP'
|
71
|
+
Sidekiq.logger.info "Received TSTP, no longer accepting new work"
|
85
72
|
launcher.quiet
|
86
|
-
when 'USR2'
|
87
|
-
if Sidekiq.options[:logfile]
|
88
|
-
Sidekiq.logger.info "Received USR2, reopening log file"
|
89
|
-
Sidekiq::Logging.reopen_logs
|
90
|
-
end
|
91
73
|
when 'TTIN'
|
92
74
|
Thread.list.each do |thread|
|
93
|
-
Sidekiq.logger.warn "Thread TID-#{thread.object_id.to_s(36)} #{thread['label']}"
|
75
|
+
Sidekiq.logger.warn "Thread TID-#{(thread.object_id ^ ::Process.pid).to_s(36)} #{thread['label']}"
|
94
76
|
if thread.backtrace
|
95
77
|
Sidekiq.logger.warn thread.backtrace.join("\n")
|
96
78
|
else
|
@@ -121,7 +103,7 @@ Sidekiq.logger.error "Created #{count*iter} jobs"
|
|
121
103
|
Monitoring = Thread.new do
|
122
104
|
watchdog("monitor thread") do
|
123
105
|
while true
|
124
|
-
sleep
|
106
|
+
sleep 1
|
125
107
|
qsize, retries = Sidekiq.redis do |conn|
|
126
108
|
conn.pipelined do
|
127
109
|
conn.llen "queue:default"
|
@@ -143,8 +125,8 @@ begin
|
|
143
125
|
#RubyProf::exclude_threads = [ Monitoring ]
|
144
126
|
#RubyProf.start
|
145
127
|
fire_event(:startup)
|
146
|
-
Sidekiq.logger.error "Simulating 1ms of latency between Sidekiq and redis"
|
147
|
-
Toxiproxy[:redis].downstream(:latency, latency: 1).apply do
|
128
|
+
#Sidekiq.logger.error "Simulating 1ms of latency between Sidekiq and redis"
|
129
|
+
#Toxiproxy[:redis].downstream(:latency, latency: 1).apply do
|
148
130
|
launcher = Sidekiq::Launcher.new(Sidekiq.options)
|
149
131
|
launcher.run
|
150
132
|
|
@@ -152,7 +134,7 @@ begin
|
|
152
134
|
signal = readable_io.first[0].gets.strip
|
153
135
|
handle_signal(launcher, signal)
|
154
136
|
end
|
155
|
-
end
|
137
|
+
#end
|
156
138
|
rescue SystemExit => e
|
157
139
|
#Sidekiq.logger.error("Profiling...")
|
158
140
|
#result = RubyProf.stop
|