worker_killer 1.0.1.83603 → 1.0.2.187732
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0a5748a9d257aeacb4e2c486fc9272e7596a0eb1209c6e36c0bc28266677006
|
4
|
+
data.tar.gz: d64b7e01f1b29bfa09abd1766671c2bf6194a01de0534a5ee1dafb9c5075ca40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc1f156405493859b4cf0ddf1cc372eae5dee1ca861e761a4bfcba59bd41702e58edae47c1e813be460183258550b9c5b8cc00eb918c33157af2a57d91ad489d
|
7
|
+
data.tar.gz: aa97b6c4cae358769e76f70b553b842bcdf79457f63fefe97c5ec3dea27fa4f5797ba519991efd29a139a35b63baacd3fd861a7ca7fc37affa0a24ff038de97c
|
@@ -14,15 +14,22 @@ module WorkerKiller
|
|
14
14
|
end
|
15
15
|
|
16
16
|
@limiter = klass.new(**opts)
|
17
|
+
@time_to_burn = false
|
17
18
|
end
|
18
19
|
|
19
|
-
def new(*_args)
|
20
|
-
configure_lifecycle(
|
20
|
+
def new(lifecycle = Delayed::Worker.lifecycle, *_args)
|
21
|
+
configure_lifecycle(lifecycle)
|
21
22
|
end
|
22
23
|
|
23
24
|
def configure_lifecycle(lifecycle)
|
25
|
+
# Count condition after every job
|
24
26
|
lifecycle.after(:perform) do |worker, *_args|
|
25
|
-
|
27
|
+
@time_to_burn = limiter.check
|
28
|
+
end
|
29
|
+
|
30
|
+
# Stop execution only after whole loop completed
|
31
|
+
lifecycle.after(:loop) do |worker, *_args|
|
32
|
+
reaction.call(limiter, killer, worker) if @time_to_burn
|
26
33
|
end
|
27
34
|
end
|
28
35
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
RSpec.describe WorkerKiller::DelayedJobPlugin::JobsLimiter do
|
2
|
+
|
3
|
+
let(:killer) {double}
|
4
|
+
subject(:plugin){ described_class.new(killer: killer) }
|
5
|
+
|
6
|
+
context 'DelayedJob initialization' do
|
7
|
+
let(:lifecycle) { double }
|
8
|
+
subject(:instance) { plugin.new(lifecycle) }
|
9
|
+
|
10
|
+
it do
|
11
|
+
expect(lifecycle).to receive(:after).with(:perform).and_yield
|
12
|
+
expect(lifecycle).to receive(:after).with(:loop).and_yield
|
13
|
+
instance
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
RSpec.describe WorkerKiller::DelayedJobPlugin::OOMLimiter do
|
2
|
+
|
3
|
+
let(:killer) {double}
|
4
|
+
subject(:plugin){ described_class.new(killer: killer) }
|
5
|
+
|
6
|
+
context 'DelayedJob initialization' do
|
7
|
+
let(:lifecycle) { double }
|
8
|
+
subject(:instance) { plugin.new(lifecycle) }
|
9
|
+
|
10
|
+
it do
|
11
|
+
expect(lifecycle).to receive(:after).with(:perform).and_yield
|
12
|
+
expect(lifecycle).to receive(:after).with(:loop).and_yield
|
13
|
+
instance
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
@@ -6,8 +6,8 @@ RSpec.describe WorkerKiller::Killer::DelayedJob do
|
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
9
|
-
let(:killer){ described_class.new() }
|
10
9
|
let(:dj){ double }
|
10
|
+
subject(:killer){ described_class.new() }
|
11
11
|
|
12
12
|
describe '#kill' do
|
13
13
|
context 'with use_quit TRUE' do
|
@@ -30,5 +30,6 @@ RSpec.describe WorkerKiller::Killer::DelayedJob do
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
33
|
+
|
33
34
|
end
|
34
35
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: worker_killer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2.187732
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samoilenko Yuri
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: get_process_mem
|
@@ -136,6 +136,8 @@ files:
|
|
136
136
|
- lib/worker_killer/middleware.rb
|
137
137
|
- lib/worker_killer/version.rb
|
138
138
|
- spec/count_limiter_spec.rb
|
139
|
+
- spec/delayed_job_plugin/jobs_limiter_spec.rb
|
140
|
+
- spec/delayed_job_plugin/oom_limiter_spec.rb
|
139
141
|
- spec/killer/delayed_job_spec.rb
|
140
142
|
- spec/killer/passenger_spec.rb
|
141
143
|
- spec/killer/signal_spec.rb
|
@@ -178,4 +180,6 @@ test_files:
|
|
178
180
|
- spec/support/logger.rb
|
179
181
|
- spec/middleware_spec.rb
|
180
182
|
- spec/spec_helper.rb
|
183
|
+
- spec/delayed_job_plugin/oom_limiter_spec.rb
|
184
|
+
- spec/delayed_job_plugin/jobs_limiter_spec.rb
|
181
185
|
- spec/memory_limiter_spec.rb
|