sidekiq 2.15.1 → 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.
- checksums.yaml +7 -0
- data/.github/contributing.md +32 -0
- data/.github/issue_template.md +9 -0
- data/.gitignore +1 -0
- data/.travis.yml +16 -17
- data/3.0-Upgrade.md +70 -0
- data/4.0-Upgrade.md +53 -0
- data/COMM-LICENSE +56 -44
- data/Changes.md +644 -1
- data/Ent-Changes.md +173 -0
- data/Gemfile +27 -0
- data/LICENSE +1 -1
- data/Pro-2.0-Upgrade.md +138 -0
- data/Pro-3.0-Upgrade.md +44 -0
- data/Pro-Changes.md +457 -3
- data/README.md +46 -29
- data/Rakefile +6 -3
- data/bin/sidekiq +4 -0
- data/bin/sidekiqctl +41 -20
- data/bin/sidekiqload +154 -0
- data/code_of_conduct.md +50 -0
- data/lib/generators/sidekiq/templates/worker.rb.erb +9 -0
- data/lib/generators/sidekiq/templates/worker_spec.rb.erb +6 -0
- data/lib/generators/sidekiq/templates/worker_test.rb.erb +8 -0
- data/lib/generators/sidekiq/worker_generator.rb +49 -0
- data/lib/sidekiq.rb +141 -29
- data/lib/sidekiq/api.rb +540 -106
- data/lib/sidekiq/cli.rb +131 -71
- data/lib/sidekiq/client.rb +168 -96
- data/lib/sidekiq/core_ext.rb +36 -8
- data/lib/sidekiq/exception_handler.rb +20 -28
- data/lib/sidekiq/extensions/action_mailer.rb +25 -5
- data/lib/sidekiq/extensions/active_record.rb +8 -4
- data/lib/sidekiq/extensions/class_methods.rb +9 -5
- data/lib/sidekiq/extensions/generic_proxy.rb +1 -0
- data/lib/sidekiq/fetch.rb +45 -101
- data/lib/sidekiq/launcher.rb +144 -30
- data/lib/sidekiq/logging.rb +69 -12
- data/lib/sidekiq/manager.rb +90 -140
- data/lib/sidekiq/middleware/chain.rb +18 -5
- data/lib/sidekiq/middleware/i18n.rb +9 -2
- data/lib/sidekiq/middleware/server/active_record.rb +1 -1
- data/lib/sidekiq/middleware/server/logging.rb +11 -11
- data/lib/sidekiq/middleware/server/retry_jobs.rb +98 -44
- data/lib/sidekiq/paginator.rb +20 -8
- data/lib/sidekiq/processor.rb +157 -96
- data/lib/sidekiq/rails.rb +109 -5
- data/lib/sidekiq/redis_connection.rb +70 -24
- data/lib/sidekiq/scheduled.rb +122 -50
- data/lib/sidekiq/testing.rb +171 -31
- data/lib/sidekiq/testing/inline.rb +1 -0
- data/lib/sidekiq/util.rb +31 -5
- data/lib/sidekiq/version.rb +2 -1
- data/lib/sidekiq/web.rb +136 -263
- data/lib/sidekiq/web/action.rb +93 -0
- data/lib/sidekiq/web/application.rb +336 -0
- data/lib/sidekiq/web/helpers.rb +278 -0
- data/lib/sidekiq/web/router.rb +100 -0
- data/lib/sidekiq/worker.rb +40 -7
- data/sidekiq.gemspec +18 -14
- data/web/assets/images/favicon.ico +0 -0
- data/web/assets/images/{status-sd8051fd480.png → status.png} +0 -0
- data/web/assets/javascripts/application.js +67 -19
- data/web/assets/javascripts/dashboard.js +138 -29
- data/web/assets/stylesheets/application.css +267 -406
- data/web/assets/stylesheets/bootstrap.css +4 -8
- data/web/locales/cs.yml +78 -0
- data/web/locales/da.yml +9 -1
- data/web/locales/de.yml +18 -9
- data/web/locales/el.yml +68 -0
- data/web/locales/en.yml +19 -4
- data/web/locales/es.yml +10 -1
- data/web/locales/fa.yml +79 -0
- data/web/locales/fr.yml +50 -32
- data/web/locales/hi.yml +75 -0
- data/web/locales/it.yml +27 -18
- data/web/locales/ja.yml +27 -12
- data/web/locales/ko.yml +8 -3
- data/web/locales/{no.yml → nb.yml} +19 -5
- data/web/locales/nl.yml +8 -3
- data/web/locales/pl.yml +0 -1
- data/web/locales/pt-br.yml +11 -4
- data/web/locales/pt.yml +8 -1
- data/web/locales/ru.yml +39 -21
- data/web/locales/sv.yml +68 -0
- data/web/locales/ta.yml +75 -0
- data/web/locales/uk.yml +76 -0
- data/web/locales/zh-cn.yml +68 -0
- data/web/locales/zh-tw.yml +68 -0
- data/web/views/_footer.erb +17 -0
- data/web/views/_job_info.erb +72 -60
- data/web/views/_nav.erb +58 -25
- data/web/views/_paging.erb +5 -5
- data/web/views/_poll_link.erb +7 -0
- data/web/views/_summary.erb +20 -14
- data/web/views/busy.erb +94 -0
- data/web/views/dashboard.erb +34 -21
- data/web/views/dead.erb +34 -0
- data/web/views/layout.erb +8 -30
- data/web/views/morgue.erb +75 -0
- data/web/views/queue.erb +37 -30
- data/web/views/queues.erb +26 -20
- data/web/views/retries.erb +60 -47
- data/web/views/retry.erb +23 -19
- data/web/views/scheduled.erb +39 -35
- data/web/views/scheduled_job_info.erb +2 -1
- metadata +152 -195
- data/Contributing.md +0 -29
- data/config.ru +0 -18
- data/lib/sidekiq/actor.rb +0 -7
- data/lib/sidekiq/capistrano.rb +0 -54
- data/lib/sidekiq/yaml_patch.rb +0 -21
- data/test/config.yml +0 -11
- data/test/env_based_config.yml +0 -11
- data/test/fake_env.rb +0 -0
- data/test/helper.rb +0 -42
- data/test/test_api.rb +0 -341
- data/test/test_cli.rb +0 -326
- data/test/test_client.rb +0 -211
- data/test/test_exception_handler.rb +0 -124
- data/test/test_extensions.rb +0 -105
- data/test/test_fetch.rb +0 -44
- data/test/test_manager.rb +0 -83
- data/test/test_middleware.rb +0 -135
- data/test/test_processor.rb +0 -160
- data/test/test_redis_connection.rb +0 -97
- data/test/test_retry.rb +0 -306
- data/test/test_scheduled.rb +0 -86
- data/test/test_scheduling.rb +0 -47
- data/test/test_sidekiq.rb +0 -37
- data/test/test_testing.rb +0 -82
- data/test/test_testing_fake.rb +0 -265
- data/test/test_testing_inline.rb +0 -92
- data/test/test_util.rb +0 -18
- data/test/test_web.rb +0 -372
- data/web/assets/images/bootstrap/glyphicons-halflings-white.png +0 -0
- data/web/assets/images/bootstrap/glyphicons-halflings.png +0 -0
- data/web/assets/images/status/active.png +0 -0
- data/web/assets/images/status/idle.png +0 -0
- data/web/assets/javascripts/locales/README.md +0 -27
- data/web/assets/javascripts/locales/jquery.timeago.ar.js +0 -96
- data/web/assets/javascripts/locales/jquery.timeago.bg.js +0 -18
- data/web/assets/javascripts/locales/jquery.timeago.bs.js +0 -49
- data/web/assets/javascripts/locales/jquery.timeago.ca.js +0 -18
- data/web/assets/javascripts/locales/jquery.timeago.cy.js +0 -20
- data/web/assets/javascripts/locales/jquery.timeago.cz.js +0 -18
- data/web/assets/javascripts/locales/jquery.timeago.da.js +0 -18
- data/web/assets/javascripts/locales/jquery.timeago.de.js +0 -18
- data/web/assets/javascripts/locales/jquery.timeago.el.js +0 -18
- data/web/assets/javascripts/locales/jquery.timeago.en-short.js +0 -20
- data/web/assets/javascripts/locales/jquery.timeago.en.js +0 -20
- data/web/assets/javascripts/locales/jquery.timeago.es.js +0 -18
- data/web/assets/javascripts/locales/jquery.timeago.et.js +0 -18
- data/web/assets/javascripts/locales/jquery.timeago.fa.js +0 -22
- data/web/assets/javascripts/locales/jquery.timeago.fi.js +0 -28
- data/web/assets/javascripts/locales/jquery.timeago.fr-short.js +0 -16
- data/web/assets/javascripts/locales/jquery.timeago.fr.js +0 -17
- data/web/assets/javascripts/locales/jquery.timeago.he.js +0 -18
- data/web/assets/javascripts/locales/jquery.timeago.hr.js +0 -49
- data/web/assets/javascripts/locales/jquery.timeago.hu.js +0 -18
- data/web/assets/javascripts/locales/jquery.timeago.hy.js +0 -18
- data/web/assets/javascripts/locales/jquery.timeago.id.js +0 -18
- data/web/assets/javascripts/locales/jquery.timeago.it.js +0 -16
- data/web/assets/javascripts/locales/jquery.timeago.ja.js +0 -19
- data/web/assets/javascripts/locales/jquery.timeago.ko.js +0 -17
- data/web/assets/javascripts/locales/jquery.timeago.lt.js +0 -20
- data/web/assets/javascripts/locales/jquery.timeago.mk.js +0 -20
- data/web/assets/javascripts/locales/jquery.timeago.nl.js +0 -20
- data/web/assets/javascripts/locales/jquery.timeago.no.js +0 -18
- data/web/assets/javascripts/locales/jquery.timeago.pl.js +0 -31
- data/web/assets/javascripts/locales/jquery.timeago.pt-br.js +0 -16
- data/web/assets/javascripts/locales/jquery.timeago.pt.js +0 -16
- data/web/assets/javascripts/locales/jquery.timeago.ro.js +0 -18
- data/web/assets/javascripts/locales/jquery.timeago.rs.js +0 -49
- data/web/assets/javascripts/locales/jquery.timeago.ru.js +0 -34
- data/web/assets/javascripts/locales/jquery.timeago.sk.js +0 -18
- data/web/assets/javascripts/locales/jquery.timeago.sl.js +0 -44
- data/web/assets/javascripts/locales/jquery.timeago.sv.js +0 -18
- data/web/assets/javascripts/locales/jquery.timeago.th.js +0 -20
- data/web/assets/javascripts/locales/jquery.timeago.tr.js +0 -16
- data/web/assets/javascripts/locales/jquery.timeago.uk.js +0 -34
- data/web/assets/javascripts/locales/jquery.timeago.uz.js +0 -19
- data/web/assets/javascripts/locales/jquery.timeago.zh-CN.js +0 -20
- data/web/assets/javascripts/locales/jquery.timeago.zh-TW.js +0 -20
- data/web/views/_poll.erb +0 -14
- data/web/views/_workers.erb +0 -29
- data/web/views/index.erb +0 -16
data/README.md
CHANGED
@@ -1,36 +1,43 @@
|
|
1
1
|
Sidekiq
|
2
2
|
==============
|
3
3
|
|
4
|
-
[![Gem Version](https://badge.fury.io/rb/sidekiq.
|
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://travis-ci.org/mperham/sidekiq.svg)](https://travis-ci.org/mperham/sidekiq)
|
7
|
+
[![Gitter Chat](https://badges.gitter.im/mperham/sidekiq.svg)](https://gitter.im/mperham/sidekiq)
|
5
8
|
|
6
9
|
|
7
10
|
Simple, efficient background processing for Ruby.
|
8
11
|
|
9
12
|
Sidekiq uses threads to handle many jobs at the same time in the
|
10
13
|
same process. It does not require Rails but will integrate tightly with
|
11
|
-
Rails
|
14
|
+
Rails to make background processing dead simple.
|
12
15
|
|
13
16
|
Sidekiq is compatible with Resque. It uses the exact same
|
14
17
|
message format as Resque so it can integrate into an existing Resque processing farm.
|
15
18
|
You can have Sidekiq and Resque run side-by-side at the same time and
|
16
19
|
use the Resque client to enqueue jobs in Redis to be processed by Sidekiq.
|
17
20
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
21
|
+
Performance
|
22
|
+
---------------
|
23
|
+
|
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
|
22
30
|
|
23
31
|
|
24
32
|
Requirements
|
25
33
|
-----------------
|
26
34
|
|
27
|
-
|
28
|
-
are untested but might work fine.
|
35
|
+
Sidekiq supports CRuby 2.0+ and JRuby 9k.
|
29
36
|
|
30
|
-
|
31
|
-
versions might work fine.
|
37
|
+
All Rails releases >= 3.2 are officially supported.
|
32
38
|
|
33
|
-
Redis 2.
|
39
|
+
Redis 2.8 or greater is required. 3.0.3+ is recommended for large
|
40
|
+
installations with thousands of worker threads.
|
34
41
|
|
35
42
|
|
36
43
|
Installation
|
@@ -42,8 +49,9 @@ Installation
|
|
42
49
|
Getting Started
|
43
50
|
-----------------
|
44
51
|
|
45
|
-
See the [
|
46
|
-
You can watch [
|
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 [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:
|
47
55
|
|
48
56
|
![Web UI](https://github.com/mperham/sidekiq/raw/master/examples/web-ui.png)
|
49
57
|
|
@@ -51,31 +59,40 @@ You can watch [Railscast #366](http://railscasts.com/episodes/366-sidekiq) to se
|
|
51
59
|
Want to Upgrade?
|
52
60
|
-------------------
|
53
61
|
|
54
|
-
I also sell Sidekiq Pro,
|
55
|
-
features, a commercial-friendly license and
|
62
|
+
I also sell Sidekiq Pro and Sidekiq Enterprise, extensions to Sidekiq which provide more
|
63
|
+
features, a commercial-friendly license and allow you to support high
|
56
64
|
quality open source development all at the same time. Please see the
|
57
|
-
[Sidekiq
|
65
|
+
[Sidekiq](http://sidekiq.org/) homepage for more detail.
|
66
|
+
|
67
|
+
Subscribe to the **[quarterly newsletter](https://tinyletter.com/sidekiq)** to stay informed about the latest
|
68
|
+
features and changes to Sidekiq and its bigger siblings.
|
58
69
|
|
59
70
|
|
60
|
-
|
71
|
+
Problems?
|
61
72
|
-----------------
|
62
73
|
|
63
|
-
Please
|
64
|
-
[#sidekiq on irc.freenode.net](irc://irc.freenode.net/#sidekiq) is dedicated to this project,
|
65
|
-
but bug reports or feature requests suggestions should still go through [issues on Github](https://github.com/mperham/sidekiq/issues).
|
74
|
+
**Please do not directly email any Sidekiq committers with questions or problems.** A community is best served when discussions are held in public.
|
66
75
|
|
67
|
-
|
68
|
-
|
69
|
-
Once archiving begins, you'll be able to visit [the archives](http://librelist.com/browser/sidekiq/) to see past threads.
|
76
|
+
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.
|
77
|
+
Searching the [issues](https://github.com/mperham/sidekiq/issues) for your problem is also a good idea.
|
70
78
|
|
79
|
+
Useful resources:
|
71
80
|
|
72
|
-
|
73
|
-
|
81
|
+
* Product documentation is in the [wiki](https://github.com/mperham/sidekiq/wiki).
|
82
|
+
* Release announcements are made to the [@sidekiq](https://twitter.com/sidekiq) Twitter account.
|
83
|
+
* Here's a [Reddit forum](https://reddit.com/r/sidekiq) dedicated to Sidekiq discussion
|
84
|
+
* The [Sidekiq tag](https://stackoverflow.com/questions/tagged/sidekiq) on Stack Overflow has lots of useful Q & A.
|
74
85
|
|
75
|
-
**
|
86
|
+
**No support via Twitter, 140 characters is not enough.**
|
87
|
+
|
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.
|
90
|
+
|
91
|
+
Thanks
|
92
|
+
-----------------
|
76
93
|
|
77
|
-
|
78
|
-
|
94
|
+
Sidekiq stays fast by using the [JProfiler java profiler](http://www.ej-technologies.com/products/jprofiler/overview.html) to find and fix
|
95
|
+
performance problems on JRuby. Unfortunately MRI does not have good multithreaded profiling tools.
|
79
96
|
|
80
97
|
|
81
98
|
License
|
@@ -87,4 +104,4 @@ Please see [LICENSE](https://github.com/mperham/sidekiq/blob/master/LICENSE) for
|
|
87
104
|
Author
|
88
105
|
-----------------
|
89
106
|
|
90
|
-
Mike Perham, [@mperham](https://twitter.com/mperham), [http://mikeperham.com](http://mikeperham.com)
|
107
|
+
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)
|
data/Rakefile
CHANGED
@@ -1,9 +1,12 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
1
2
|
require 'rake/testtask'
|
2
3
|
Rake::TestTask.new(:test) do |test|
|
3
|
-
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/sidekiq
CHANGED
data/bin/sidekiqctl
CHANGED
@@ -3,16 +3,32 @@
|
|
3
3
|
require 'fileutils'
|
4
4
|
|
5
5
|
class Sidekiqctl
|
6
|
-
|
7
|
-
|
6
|
+
DEFAULT_KILL_TIMEOUT = 10
|
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
|
8
24
|
|
9
25
|
def initialize(stage, pidfile, timeout)
|
10
26
|
@stage = stage
|
11
27
|
@pidfile = pidfile
|
12
|
-
@
|
28
|
+
@kill_timeout = timeout
|
13
29
|
|
14
30
|
done('No pidfile given', :error) if !pidfile
|
15
|
-
done("Pidfile #{pidfile} does not exist", :
|
31
|
+
done("Pidfile #{pidfile} does not exist", :warn) if !File.exist?(pidfile)
|
16
32
|
done('Invalid pidfile content', :error) if pid == 0
|
17
33
|
|
18
34
|
fetch_process
|
@@ -20,14 +36,18 @@ class Sidekiqctl
|
|
20
36
|
begin
|
21
37
|
send(stage)
|
22
38
|
rescue NoMethodError
|
23
|
-
done
|
39
|
+
done "Invalid command: #{stage}", :error
|
24
40
|
end
|
25
41
|
end
|
26
42
|
|
27
43
|
def fetch_process
|
28
|
-
Process.
|
44
|
+
Process.kill(0, pid)
|
29
45
|
rescue Errno::ESRCH
|
30
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
|
31
51
|
end
|
32
52
|
|
33
53
|
def done(msg, error = nil)
|
@@ -40,7 +60,7 @@ class Sidekiqctl
|
|
40
60
|
end
|
41
61
|
|
42
62
|
def pid
|
43
|
-
File.read(pidfile).to_i
|
63
|
+
@pid ||= File.read(pidfile).to_i
|
44
64
|
end
|
45
65
|
|
46
66
|
def quiet
|
@@ -49,12 +69,14 @@ class Sidekiqctl
|
|
49
69
|
|
50
70
|
def stop
|
51
71
|
`kill -TERM #{pid}`
|
52
|
-
|
72
|
+
kill_timeout.times do
|
53
73
|
begin
|
54
|
-
Process.
|
74
|
+
Process.kill(0, pid)
|
55
75
|
rescue Errno::ESRCH
|
56
76
|
FileUtils.rm_f pidfile
|
57
77
|
done 'Sidekiq shut down gracefully.'
|
78
|
+
rescue Errno::EPERM
|
79
|
+
done 'Not permitted to shut down Sidekiq.'
|
58
80
|
end
|
59
81
|
sleep 1
|
60
82
|
end
|
@@ -62,17 +84,16 @@ class Sidekiqctl
|
|
62
84
|
FileUtils.rm_f pidfile
|
63
85
|
done 'Sidekiq shut down forcefully.'
|
64
86
|
end
|
65
|
-
|
66
|
-
def shutdown
|
67
|
-
quiet
|
68
|
-
stop
|
69
|
-
end
|
70
|
-
|
87
|
+
alias_method :shutdown, :stop
|
71
88
|
end
|
72
89
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
90
|
+
if ARGV.length < 2
|
91
|
+
Sidekiqctl.print_usage
|
92
|
+
else
|
93
|
+
stage = ARGV[0]
|
94
|
+
pidfile = ARGV[1]
|
95
|
+
timeout = ARGV[2].to_i
|
96
|
+
timeout = Sidekiqctl::DEFAULT_KILL_TIMEOUT if timeout == 0
|
77
97
|
|
78
|
-
Sidekiqctl.new(stage, pidfile, timeout)
|
98
|
+
Sidekiqctl.new(stage, pidfile, timeout)
|
99
|
+
end
|
data/bin/sidekiqload
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Quiet some warnings we see when running in warning mode:
|
4
|
+
# RUBYOPT=-w bundle exec sidekiq
|
5
|
+
$TESTING = false
|
6
|
+
|
7
|
+
#require 'ruby-prof'
|
8
|
+
Bundler.require(:default)
|
9
|
+
|
10
|
+
require_relative '../lib/sidekiq/cli'
|
11
|
+
require_relative '../lib/sidekiq/launcher'
|
12
|
+
|
13
|
+
include Sidekiq::Util
|
14
|
+
|
15
|
+
Sidekiq.configure_server do |config|
|
16
|
+
#config.options[:concurrency] = 1
|
17
|
+
config.redis = { db: 13 }
|
18
|
+
config.options[:queues] << 'default'
|
19
|
+
config.logger.level = Logger::ERROR
|
20
|
+
config.average_scheduled_poll_interval = 2
|
21
|
+
config.reliable! if defined?(Sidekiq::Pro)
|
22
|
+
end
|
23
|
+
|
24
|
+
class LoadWorker
|
25
|
+
include Sidekiq::Worker
|
26
|
+
sidekiq_options retry: 1
|
27
|
+
sidekiq_retry_in do |x|
|
28
|
+
1
|
29
|
+
end
|
30
|
+
|
31
|
+
def perform(idx)
|
32
|
+
#raise idx.to_s if idx % 100 == 1
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# brew tap shopify/shopify
|
37
|
+
# brew install toxiproxy
|
38
|
+
# gem install toxiproxy
|
39
|
+
#require 'toxiproxy'
|
40
|
+
# simulate a non-localhost network for realer-world conditions.
|
41
|
+
# 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
|
+
#}])
|
47
|
+
|
48
|
+
self_read, self_write = IO.pipe
|
49
|
+
%w(INT TERM USR1 USR2 TTIN).each do |sig|
|
50
|
+
begin
|
51
|
+
trap sig do
|
52
|
+
self_write.puts(sig)
|
53
|
+
end
|
54
|
+
rescue ArgumentError
|
55
|
+
puts "Signal #{sig} not supported"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
Sidekiq.redis {|c| c.flushdb}
|
60
|
+
def handle_signal(launcher, sig)
|
61
|
+
Sidekiq.logger.debug "Got #{sig} signal"
|
62
|
+
case sig
|
63
|
+
when 'INT'
|
64
|
+
# Handle Ctrl-C in JRuby like MRI
|
65
|
+
# http://jira.codehaus.org/browse/JRUBY-4637
|
66
|
+
raise Interrupt
|
67
|
+
when 'TERM'
|
68
|
+
# Heroku sends TERM and then waits 10 seconds for process to exit.
|
69
|
+
raise Interrupt
|
70
|
+
when 'USR1'
|
71
|
+
Sidekiq.logger.info "Received USR1, no longer accepting new work"
|
72
|
+
launcher.quiet
|
73
|
+
when 'USR2'
|
74
|
+
if Sidekiq.options[:logfile]
|
75
|
+
Sidekiq.logger.info "Received USR2, reopening log file"
|
76
|
+
Sidekiq::Logging.reopen_logs
|
77
|
+
end
|
78
|
+
when 'TTIN'
|
79
|
+
Thread.list.each do |thread|
|
80
|
+
Sidekiq.logger.warn "Thread TID-#{thread.object_id.to_s(36)} #{thread['label']}"
|
81
|
+
if thread.backtrace
|
82
|
+
Sidekiq.logger.warn thread.backtrace.join("\n")
|
83
|
+
else
|
84
|
+
Sidekiq.logger.warn "<no backtrace available>"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def Process.rss
|
91
|
+
`ps -o rss= -p #{Process.pid}`.chomp.to_i
|
92
|
+
end
|
93
|
+
|
94
|
+
iter = 10
|
95
|
+
count = 10_000
|
96
|
+
|
97
|
+
iter.times do
|
98
|
+
arr = Array.new(count) do
|
99
|
+
[]
|
100
|
+
end
|
101
|
+
count.times do |idx|
|
102
|
+
arr[idx][0] = idx
|
103
|
+
end
|
104
|
+
Sidekiq::Client.push_bulk('class' => LoadWorker, 'args' => arr)
|
105
|
+
end
|
106
|
+
Sidekiq.logger.error "Created #{count*iter} jobs"
|
107
|
+
|
108
|
+
Monitoring = Thread.new do
|
109
|
+
watchdog("monitor thread") do
|
110
|
+
while true
|
111
|
+
sleep 1
|
112
|
+
qsize, retries = Sidekiq.redis do |conn|
|
113
|
+
conn.pipelined do
|
114
|
+
conn.llen "queue:default"
|
115
|
+
conn.zcard "retry"
|
116
|
+
end
|
117
|
+
end.map(&:to_i)
|
118
|
+
total = qsize + retries
|
119
|
+
#GC.start
|
120
|
+
Sidekiq.logger.error("RSS: #{Process.rss} Pending: #{total}")
|
121
|
+
if total == 0
|
122
|
+
Sidekiq.logger.error("Done")
|
123
|
+
exit(0)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
begin
|
130
|
+
#RubyProf::exclude_threads = [ Monitoring ]
|
131
|
+
#RubyProf.start
|
132
|
+
fire_event(:startup)
|
133
|
+
#Sidekiq.logger.error "Simulating 1ms of latency between Sidekiq and redis"
|
134
|
+
#Toxiproxy[:redis].downstream(:latency, latency: 1).apply do
|
135
|
+
launcher = Sidekiq::Launcher.new(Sidekiq.options)
|
136
|
+
launcher.run
|
137
|
+
|
138
|
+
while readable_io = IO.select([self_read])
|
139
|
+
signal = readable_io.first[0].gets.strip
|
140
|
+
handle_signal(launcher, signal)
|
141
|
+
end
|
142
|
+
#end
|
143
|
+
rescue SystemExit => e
|
144
|
+
#Sidekiq.logger.error("Profiling...")
|
145
|
+
#result = RubyProf.stop
|
146
|
+
#printer = RubyProf::GraphHtmlPrinter.new(result)
|
147
|
+
#printer.print(File.new("output.html", "w"), :min_percent => 1)
|
148
|
+
# normal
|
149
|
+
rescue => e
|
150
|
+
raise e if $DEBUG
|
151
|
+
STDERR.puts e.message
|
152
|
+
STDERR.puts e.backtrace.join("\n")
|
153
|
+
exit 1
|
154
|
+
end
|
data/code_of_conduct.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting the project maintainer at mperham AT gmail.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
|
45
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
46
|
+
version 1.3.0, available at
|
47
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
48
|
+
|
49
|
+
[homepage]: http://contributor-covenant.org
|
50
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|