sidekiq 4.2.10 → 6.5.7
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/Changes.md +573 -1
- data/LICENSE +3 -3
- data/README.md +25 -34
- data/bin/sidekiq +27 -3
- data/bin/sidekiqload +81 -74
- data/bin/sidekiqmon +8 -0
- 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/job_spec.rb.erb +6 -0
- data/lib/generators/sidekiq/templates/{worker_test.rb.erb → job_test.rb.erb} +1 -1
- data/lib/sidekiq/api.rb +585 -285
- data/lib/sidekiq/cli.rb +256 -233
- data/lib/sidekiq/client.rb +86 -83
- data/lib/sidekiq/component.rb +65 -0
- data/lib/sidekiq/delay.rb +43 -0
- data/lib/sidekiq/extensions/action_mailer.rb +13 -22
- data/lib/sidekiq/extensions/active_record.rb +13 -10
- data/lib/sidekiq/extensions/class_methods.rb +14 -11
- data/lib/sidekiq/extensions/generic_proxy.rb +13 -5
- data/lib/sidekiq/fetch.rb +50 -40
- data/lib/sidekiq/job.rb +13 -0
- data/lib/sidekiq/job_logger.rb +51 -0
- data/lib/sidekiq/job_retry.rb +282 -0
- data/lib/sidekiq/job_util.rb +71 -0
- data/lib/sidekiq/launcher.rb +184 -90
- data/lib/sidekiq/logger.rb +156 -0
- data/lib/sidekiq/manager.rb +43 -45
- data/lib/sidekiq/metrics/deploy.rb +47 -0
- data/lib/sidekiq/metrics/query.rb +153 -0
- data/lib/sidekiq/metrics/shared.rb +94 -0
- data/lib/sidekiq/metrics/tracking.rb +134 -0
- data/lib/sidekiq/middleware/chain.rb +102 -46
- data/lib/sidekiq/middleware/current_attributes.rb +63 -0
- data/lib/sidekiq/middleware/i18n.rb +7 -7
- data/lib/sidekiq/middleware/modules.rb +21 -0
- data/lib/sidekiq/monitor.rb +133 -0
- data/lib/sidekiq/paginator.rb +20 -16
- data/lib/sidekiq/processor.rb +176 -91
- data/lib/sidekiq/rails.rb +41 -96
- data/lib/sidekiq/redis_client_adapter.rb +154 -0
- data/lib/sidekiq/redis_connection.rb +117 -48
- data/lib/sidekiq/ring_buffer.rb +29 -0
- data/lib/sidekiq/scheduled.rb +134 -44
- data/lib/sidekiq/sd_notify.rb +149 -0
- data/lib/sidekiq/systemd.rb +24 -0
- data/lib/sidekiq/testing/inline.rb +6 -5
- data/lib/sidekiq/testing.rb +80 -61
- data/lib/sidekiq/transaction_aware_client.rb +45 -0
- data/lib/sidekiq/version.rb +2 -1
- data/lib/sidekiq/web/action.rb +15 -15
- data/lib/sidekiq/web/application.rb +129 -86
- data/lib/sidekiq/web/csrf_protection.rb +180 -0
- data/lib/sidekiq/web/helpers.rb +170 -83
- data/lib/sidekiq/web/router.rb +23 -19
- data/lib/sidekiq/web.rb +69 -109
- data/lib/sidekiq/worker.rb +290 -41
- data/lib/sidekiq.rb +185 -77
- data/sidekiq.gemspec +23 -27
- data/web/assets/images/apple-touch-icon.png +0 -0
- data/web/assets/javascripts/application.js +112 -61
- 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.js +70 -91
- data/web/assets/javascripts/graph.js +16 -0
- data/web/assets/javascripts/metrics.js +262 -0
- data/web/assets/stylesheets/application-dark.css +143 -0
- data/web/assets/stylesheets/application-rtl.css +242 -0
- data/web/assets/stylesheets/application.css +364 -144
- data/web/assets/stylesheets/bootstrap-rtl.min.css +9 -0
- data/web/assets/stylesheets/bootstrap.css +2 -2
- data/web/locales/ar.yml +87 -0
- data/web/locales/de.yml +14 -2
- data/web/locales/el.yml +43 -19
- data/web/locales/en.yml +15 -1
- data/web/locales/es.yml +22 -5
- data/web/locales/fa.yml +1 -0
- data/web/locales/fr.yml +10 -3
- data/web/locales/he.yml +79 -0
- data/web/locales/ja.yml +19 -4
- data/web/locales/lt.yml +83 -0
- data/web/locales/pl.yml +4 -4
- data/web/locales/pt-br.yml +27 -9
- data/web/locales/ru.yml +4 -0
- data/web/locales/ur.yml +80 -0
- data/web/locales/vi.yml +83 -0
- data/web/locales/zh-cn.yml +36 -11
- data/web/locales/zh-tw.yml +32 -7
- data/web/views/_footer.erb +5 -2
- data/web/views/_job_info.erb +3 -2
- data/web/views/_nav.erb +5 -19
- data/web/views/_paging.erb +1 -1
- data/web/views/_poll_link.erb +2 -5
- data/web/views/_summary.erb +7 -7
- data/web/views/busy.erb +62 -24
- data/web/views/dashboard.erb +24 -15
- data/web/views/dead.erb +3 -3
- data/web/views/layout.erb +14 -3
- data/web/views/metrics.erb +69 -0
- data/web/views/metrics_for_job.erb +87 -0
- data/web/views/morgue.erb +9 -6
- data/web/views/queue.erb +26 -12
- data/web/views/queues.erb +12 -2
- data/web/views/retries.erb +14 -7
- data/web/views/retry.erb +3 -3
- data/web/views/scheduled.erb +7 -4
- metadata +66 -206
- data/.github/contributing.md +0 -32
- data/.github/issue_template.md +0 -9
- data/.gitignore +0 -12
- data/.travis.yml +0 -18
- data/3.0-Upgrade.md +0 -70
- data/4.0-Upgrade.md +0 -53
- data/COMM-LICENSE +0 -95
- data/Ent-Changes.md +0 -173
- data/Gemfile +0 -29
- data/Pro-2.0-Upgrade.md +0 -138
- data/Pro-3.0-Upgrade.md +0 -44
- data/Pro-Changes.md +0 -628
- data/Rakefile +0 -12
- data/bin/sidekiqctl +0 -99
- data/code_of_conduct.md +0 -50
- data/lib/generators/sidekiq/templates/worker_spec.rb.erb +0 -6
- data/lib/generators/sidekiq/worker_generator.rb +0 -49
- data/lib/sidekiq/core_ext.rb +0 -119
- data/lib/sidekiq/exception_handler.rb +0 -31
- data/lib/sidekiq/logging.rb +0 -106
- data/lib/sidekiq/middleware/server/active_record.rb +0 -13
- data/lib/sidekiq/middleware/server/logging.rb +0 -31
- data/lib/sidekiq/middleware/server/retry_jobs.rb +0 -205
- data/lib/sidekiq/util.rb +0 -63
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
|
-
|
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)
|
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,47 +10,43 @@ 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
|
25
|
-
|
26
|
-
Sidekiq
|
27
|
-
Sidekiq
|
28
|
-
|
29
|
-
|
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
|
|
25
|
+
This benchmark can be found in `bin/sidekiqload` and assumes a Redis network latency of 1ms.
|
31
26
|
|
32
27
|
Requirements
|
33
28
|
-----------------
|
34
29
|
|
35
|
-
|
36
|
-
|
37
|
-
All Rails releases >= 3.2 are officially supported.
|
30
|
+
- Redis: 4.0+
|
31
|
+
- Ruby: MRI 2.5+ or JRuby 9.2+.
|
38
32
|
|
39
|
-
|
40
|
-
installations with thousands of worker threads.
|
33
|
+
Sidekiq 6.0 supports Rails 5.0+ but does not require it.
|
41
34
|
|
42
35
|
|
43
36
|
Installation
|
44
37
|
-----------------
|
45
38
|
|
46
|
-
|
39
|
+
bundle add sidekiq
|
47
40
|
|
48
41
|
|
49
42
|
Getting Started
|
50
43
|
-----------------
|
51
44
|
|
52
45
|
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
|
46
|
+
You can watch [this YouTube playlist](https://www.youtube.com/playlist?list=PLjeHh2LSCFrWGT5uVjUuFKAcrcj5kSai1) to learn all about
|
54
47
|
Sidekiq and see its features in action. Here's the Web UI:
|
55
48
|
|
56
|
-
![Web UI](https://github.com/mperham/sidekiq/raw/
|
49
|
+
![Web UI](https://github.com/mperham/sidekiq/raw/main/examples/web-ui.png)
|
57
50
|
|
58
51
|
|
59
52
|
Want to Upgrade?
|
@@ -62,7 +55,7 @@ Want to Upgrade?
|
|
62
55
|
I also sell Sidekiq Pro and Sidekiq Enterprise, extensions to Sidekiq which provide more
|
63
56
|
features, a commercial-friendly license and allow you to support high
|
64
57
|
quality open source development all at the same time. Please see the
|
65
|
-
[Sidekiq](
|
58
|
+
[Sidekiq](https://sidekiq.org/) homepage for more detail.
|
66
59
|
|
67
60
|
Subscribe to the **[quarterly newsletter](https://tinyletter.com/sidekiq)** to stay informed about the latest
|
68
61
|
features and changes to Sidekiq and its bigger siblings.
|
@@ -76,32 +69,30 @@ Problems?
|
|
76
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.
|
77
70
|
Searching the [issues](https://github.com/mperham/sidekiq/issues) for your problem is also a good idea.
|
78
71
|
|
72
|
+
Sidekiq Pro and Sidekiq Enterprise customers get private email support. You can purchase at https://sidekiq.org; email support@contribsys.com for help.
|
73
|
+
|
79
74
|
Useful resources:
|
80
75
|
|
81
76
|
* Product documentation is in the [wiki](https://github.com/mperham/sidekiq/wiki).
|
82
|
-
*
|
83
|
-
* Here's a [Reddit forum](https://reddit.com/r/sidekiq) dedicated to Sidekiq discussion
|
77
|
+
* Occasional announcements are made to the [@sidekiq](https://twitter.com/sidekiq) Twitter account.
|
84
78
|
* The [Sidekiq tag](https://stackoverflow.com/questions/tagged/sidekiq) on Stack Overflow has lots of useful Q & A.
|
85
79
|
|
86
|
-
**No support via Twitter, 140 characters is not enough.**
|
87
|
-
|
88
80
|
Every Friday morning is Sidekiq happy hour: I video chat and answer questions.
|
89
|
-
See the [Sidekiq support page](
|
81
|
+
See the [Sidekiq support page](https://sidekiq.org/support.html) for details.
|
90
82
|
|
91
|
-
|
83
|
+
Contributing
|
92
84
|
-----------------
|
93
85
|
|
94
|
-
|
95
|
-
performance problems on JRuby. Unfortunately MRI does not have good multithreaded profiling tools.
|
86
|
+
Please see [the contributing guidelines](https://github.com/mperham/sidekiq/blob/main/.github/contributing.md).
|
96
87
|
|
97
88
|
|
98
89
|
License
|
99
90
|
-----------------
|
100
91
|
|
101
|
-
Please see [LICENSE](https://github.com/mperham/sidekiq/blob/
|
92
|
+
Please see [LICENSE](https://github.com/mperham/sidekiq/blob/main/LICENSE) for licensing details.
|
102
93
|
|
103
94
|
|
104
95
|
Author
|
105
96
|
-----------------
|
106
97
|
|
107
|
-
Mike Perham, [@
|
98
|
+
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
@@ -4,15 +4,39 @@
|
|
4
4
|
# RUBYOPT=-w bundle exec sidekiq
|
5
5
|
$TESTING = false
|
6
6
|
|
7
|
-
require_relative
|
7
|
+
require_relative "../lib/sidekiq/cli"
|
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
|
8
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
|
-
|
16
|
-
|
34
|
+
if Sidekiq.error_handlers.length == 0
|
35
|
+
warn e.message
|
36
|
+
warn 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
@@ -4,18 +4,22 @@
|
|
4
4
|
# RUBYOPT=-w bundle exec sidekiq
|
5
5
|
$TESTING = false
|
6
6
|
|
7
|
-
#require
|
8
|
-
|
7
|
+
# require "ruby-prof"
|
8
|
+
require "bundler/setup"
|
9
|
+
Bundler.require(:default, :load_test)
|
9
10
|
|
10
|
-
require_relative
|
11
|
-
require_relative
|
11
|
+
require_relative "../lib/sidekiq/cli"
|
12
|
+
require_relative "../lib/sidekiq/launcher"
|
12
13
|
|
13
|
-
|
14
|
+
if ENV["SIDEKIQ_REDIS_CLIENT"]
|
15
|
+
Sidekiq::RedisConnection.adapter = :redis_client
|
16
|
+
end
|
14
17
|
|
15
18
|
Sidekiq.configure_server do |config|
|
16
|
-
|
17
|
-
config.redis = {
|
18
|
-
config.
|
19
|
+
config.options[:concurrency] = 10
|
20
|
+
config.redis = {db: 13, port: 6380}
|
21
|
+
# config.redis = { db: 13, port: 6380, driver: :hiredis}
|
22
|
+
config.options[:queues] << "default"
|
19
23
|
config.logger.level = Logger::ERROR
|
20
24
|
config.average_scheduled_poll_interval = 2
|
21
25
|
config.reliable! if defined?(Sidekiq::Pro)
|
@@ -28,56 +32,50 @@ class LoadWorker
|
|
28
32
|
1
|
29
33
|
end
|
30
34
|
|
31
|
-
def perform(idx)
|
32
|
-
|
35
|
+
def perform(idx, ts = nil)
|
36
|
+
puts(Time.now.to_f - ts) if !ts.nil?
|
37
|
+
# raise idx.to_s if idx % 100 == 1
|
33
38
|
end
|
34
39
|
end
|
35
40
|
|
36
41
|
# brew tap shopify/shopify
|
37
42
|
# brew install toxiproxy
|
38
|
-
#
|
39
|
-
|
43
|
+
# run `toxiproxy-server` in a separate terminal window.
|
44
|
+
require "toxiproxy"
|
40
45
|
# simulate a non-localhost network for realer-world conditions.
|
41
46
|
# adding 1ms of network latency has an ENORMOUS impact on benchmarks
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
+
Toxiproxy.populate([{
|
48
|
+
name: "redis",
|
49
|
+
listen: "127.0.0.1:6380",
|
50
|
+
upstream: "127.0.0.1:6379"
|
51
|
+
}])
|
47
52
|
|
48
53
|
self_read, self_write = IO.pipe
|
49
|
-
%w
|
50
|
-
|
51
|
-
|
52
|
-
self_write.puts(sig)
|
53
|
-
end
|
54
|
-
rescue ArgumentError
|
55
|
-
puts "Signal #{sig} not supported"
|
54
|
+
%w[INT TERM TSTP TTIN].each do |sig|
|
55
|
+
trap sig do
|
56
|
+
self_write.puts(sig)
|
56
57
|
end
|
58
|
+
rescue ArgumentError
|
59
|
+
puts "Signal #{sig} not supported"
|
57
60
|
end
|
58
61
|
|
59
|
-
Sidekiq.redis {|c| c.flushdb}
|
62
|
+
Sidekiq.redis { |c| c.flushdb }
|
60
63
|
def handle_signal(launcher, sig)
|
61
64
|
Sidekiq.logger.debug "Got #{sig} signal"
|
62
65
|
case sig
|
63
|
-
when
|
66
|
+
when "INT"
|
64
67
|
# Handle Ctrl-C in JRuby like MRI
|
65
68
|
# http://jira.codehaus.org/browse/JRUBY-4637
|
66
69
|
raise Interrupt
|
67
|
-
when
|
68
|
-
# Heroku sends TERM and then waits
|
70
|
+
when "TERM"
|
71
|
+
# Heroku sends TERM and then waits 30 seconds for process to exit.
|
69
72
|
raise Interrupt
|
70
|
-
when
|
71
|
-
Sidekiq.logger.info "Received
|
73
|
+
when "TSTP"
|
74
|
+
Sidekiq.logger.info "Received TSTP, no longer accepting new work"
|
72
75
|
launcher.quiet
|
73
|
-
when
|
74
|
-
if Sidekiq.options[:logfile]
|
75
|
-
Sidekiq.logger.info "Received USR2, reopening log file"
|
76
|
-
Sidekiq::Logging.reopen_logs
|
77
|
-
end
|
78
|
-
when 'TTIN'
|
76
|
+
when "TTIN"
|
79
77
|
Thread.list.each do |thread|
|
80
|
-
Sidekiq.logger.warn "Thread TID-#{thread.object_id.to_s(36)} #{thread[
|
78
|
+
Sidekiq.logger.warn "Thread TID-#{(thread.object_id ^ ::Process.pid).to_s(36)} #{thread["label"]}"
|
81
79
|
if thread.backtrace
|
82
80
|
Sidekiq.logger.warn thread.backtrace.join("\n")
|
83
81
|
else
|
@@ -95,60 +93,69 @@ iter = 10
|
|
95
93
|
count = 10_000
|
96
94
|
|
97
95
|
iter.times do
|
98
|
-
arr = Array.new(count)
|
99
|
-
|
100
|
-
end
|
101
|
-
count.times do |idx|
|
102
|
-
arr[idx][0] = idx
|
103
|
-
end
|
104
|
-
Sidekiq::Client.push_bulk('class' => LoadWorker, 'args' => arr)
|
96
|
+
arr = Array.new(count) { |idx| [idx] }
|
97
|
+
Sidekiq::Client.push_bulk("class" => LoadWorker, "args" => arr)
|
105
98
|
end
|
106
|
-
Sidekiq.logger.error "Created #{count*iter} jobs"
|
99
|
+
Sidekiq.logger.error "Created #{count * iter} jobs"
|
100
|
+
|
101
|
+
start = Time.now
|
107
102
|
|
108
103
|
Monitoring = Thread.new do
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
104
|
+
while true
|
105
|
+
sleep 0.2
|
106
|
+
qsize = Sidekiq.redis do |conn|
|
107
|
+
conn.llen "queue:default"
|
108
|
+
end
|
109
|
+
total = qsize
|
110
|
+
# Sidekiq.logger.error("RSS: #{Process.rss} Pending: #{total}")
|
111
|
+
if total == 0
|
112
|
+
Sidekiq.logger.error("Done, #{iter * count} jobs in #{Time.now - start} sec")
|
113
|
+
Sidekiq.logger.error("Now here's the latency for three jobs")
|
114
|
+
|
115
|
+
LoadWorker.perform_async(1, Time.now.to_f)
|
116
|
+
LoadWorker.perform_async(2, Time.now.to_f)
|
117
|
+
LoadWorker.perform_async(3, Time.now.to_f)
|
118
|
+
|
119
|
+
sleep 0.2
|
120
|
+
exit(0)
|
125
121
|
end
|
126
122
|
end
|
127
123
|
end
|
128
124
|
|
125
|
+
def with_latency(latency, &block)
|
126
|
+
Sidekiq.logger.error "Simulating #{latency}ms of latency between Sidekiq and redis"
|
127
|
+
if latency > 0
|
128
|
+
Toxiproxy[:redis].downstream(:latency, latency: latency).apply(&block)
|
129
|
+
else
|
130
|
+
yield
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
129
134
|
begin
|
130
|
-
#RubyProf::exclude_threads = [ Monitoring ]
|
131
|
-
#RubyProf.start
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
135
|
+
# RubyProf::exclude_threads = [ Monitoring ]
|
136
|
+
# RubyProf.start
|
137
|
+
events = Sidekiq.options[:lifecycle_events][:startup]
|
138
|
+
events.each(&:call)
|
139
|
+
events.clear
|
140
|
+
|
141
|
+
with_latency(Integer(ENV.fetch("LATENCY", "1"))) do
|
142
|
+
launcher = Sidekiq::Launcher.new(Sidekiq)
|
136
143
|
launcher.run
|
137
144
|
|
138
145
|
while readable_io = IO.select([self_read])
|
139
146
|
signal = readable_io.first[0].gets.strip
|
140
147
|
handle_signal(launcher, signal)
|
141
148
|
end
|
142
|
-
|
149
|
+
end
|
143
150
|
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)
|
151
|
+
# Sidekiq.logger.error("Profiling...")
|
152
|
+
# result = RubyProf.stop
|
153
|
+
# printer = RubyProf::GraphHtmlPrinter.new(result)
|
154
|
+
# printer.print(File.new("output.html", "w"), :min_percent => 1)
|
148
155
|
# normal
|
149
156
|
rescue => e
|
150
157
|
raise e if $DEBUG
|
151
|
-
|
152
|
-
|
158
|
+
warn e.message
|
159
|
+
warn e.backtrace.join("\n")
|
153
160
|
exit 1
|
154
161
|
end
|
data/bin/sidekiqmon
ADDED
@@ -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
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
<% module_namespacing do -%>
|
3
|
-
class <%= class_name %>
|
3
|
+
class <%= class_name %>JobTest < Minitest::Test
|
4
4
|
def test_example
|
5
5
|
skip "add some examples to (or delete) #{__FILE__}"
|
6
6
|
end
|