worker_killer 1.0.2.187805 → 1.0.2.187852
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: 0cde26e5d9705270605884443084f3dada5182e12ce9cba38c91ef5206837ced
|
4
|
+
data.tar.gz: 8ebe3a9edafa87bafb84edd1f52277bb62dc9db7484fa4f0515ec0acaaf5d9ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bb89c7851d4dd6a127fa33273ca6c64e899c1d03d7e44709435a940944e7dff074a2f56f794221790464836d174fbb2dfa02f1ee08cf333a4b05342c6b0e1d7
|
7
|
+
data.tar.gz: ca33356f8884b182c7ad06883b337168b563f105829f5f587471b87972d76b3738e97f5bb7e6cbcfe335d630cf386cb2026d805eb1ff1a264d60961ae5d27735
|
@@ -17,12 +17,12 @@ module WorkerKiller
|
|
17
17
|
@started_at ||= Time.now
|
18
18
|
|
19
19
|
if @verbose
|
20
|
-
logger.info "#{self}: worker (pid: #{Process.pid}) has #{@left} left before being limited"
|
20
|
+
logger.info "#{self.class}: worker (pid: #{Process.pid}) has #{@left} left before being limited"
|
21
21
|
end
|
22
22
|
|
23
23
|
return false if (@left -= 1) > 0
|
24
24
|
|
25
|
-
logger.warn "#{self}: worker (pid: #{Process.pid}) exceeds max number of requests (limit: #{@limit})"
|
25
|
+
logger.warn "#{self.class}: worker (pid: #{Process.pid}) exceeds max number of requests (limit: #{@limit})"
|
26
26
|
|
27
27
|
true
|
28
28
|
end
|
@@ -4,18 +4,18 @@ module WorkerKiller
|
|
4
4
|
|
5
5
|
def do_kill(sig, pid, alive_sec, dj:, **_params)
|
6
6
|
if sig == :KILL
|
7
|
-
logger.error "#{self} force to #{sig} self (pid: #{pid}) alive: #{alive_sec} sec (trial #{kill_attempts})"
|
7
|
+
logger.error "#{self.class}: force to #{sig} self (pid: #{pid}) alive: #{alive_sec} sec (trial #{kill_attempts})"
|
8
8
|
Process.kill sig, pid
|
9
9
|
return
|
10
10
|
end
|
11
11
|
|
12
12
|
dj.stop
|
13
|
-
logger.info "#{self} try to stop DelayedJob due to #{sig} self (pid: #{pid}) alive: #{alive_sec} sec (trial #{kill_attempts})"
|
13
|
+
logger.info "#{self.class}: try to stop DelayedJob due to #{sig} self (pid: #{pid}) alive: #{alive_sec} sec (trial #{kill_attempts})"
|
14
14
|
|
15
15
|
return if sig != :TERM
|
16
16
|
|
17
17
|
if @termination
|
18
|
-
logger.warn "#{self} force to #{sig} self (pid: #{pid}) alive: #{alive_sec} sec (trial #{kill_attempts})"
|
18
|
+
logger.warn "#{self.class}: force to #{sig} self (pid: #{pid}) alive: #{alive_sec} sec (trial #{kill_attempts})"
|
19
19
|
Process.kill sig, pid
|
20
20
|
else
|
21
21
|
@termination = true
|
data/lib/worker_killer/killer.rb
CHANGED
@@ -4,7 +4,7 @@ module WorkerKiller
|
|
4
4
|
|
5
5
|
attr_accessor :config, :kill_attempts, :logger
|
6
6
|
|
7
|
-
def initialize(logger:
|
7
|
+
def initialize(logger: nil, **_kwargs)
|
8
8
|
@logger = logger
|
9
9
|
@config = WorkerKiller.configuration
|
10
10
|
@kill_attempts = 0
|
@@ -27,6 +27,10 @@ module WorkerKiller
|
|
27
27
|
raise 'Not Implemented'
|
28
28
|
end
|
29
29
|
# :nocov:
|
30
|
+
|
31
|
+
def logger
|
32
|
+
@logger || WorkerKiller.configuration.logger
|
33
|
+
end
|
30
34
|
|
31
35
|
end
|
32
36
|
end
|
@@ -24,13 +24,13 @@ module WorkerKiller
|
|
24
24
|
|
25
25
|
rss = GetProcessMem.new.bytes
|
26
26
|
if @verbose
|
27
|
-
logger.info "#{self}: worker (pid: #{Process.pid}) using #{rss} bytes(#{rss / 1024 / 1024}mb)."
|
27
|
+
logger.info "#{self.class}: worker (pid: #{Process.pid}) using #{rss} bytes(#{rss / 1024 / 1024}mb)."
|
28
28
|
end
|
29
29
|
@check_count = 0
|
30
30
|
|
31
31
|
return false if rss <= @limit
|
32
32
|
|
33
|
-
logger.warn "#{self}: worker (pid: #{Process.pid}) exceeds memory limit (#{rss} bytes > #{@limit} bytes)"
|
33
|
+
logger.warn "#{self.class}: worker (pid: #{Process.pid}) exceeds memory limit (#{rss} bytes > #{@limit} bytes)"
|
34
34
|
|
35
35
|
true
|
36
36
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: worker_killer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.2.
|
4
|
+
version: 1.0.2.187852
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samoilenko Yuri
|
@@ -171,15 +171,15 @@ signing_key:
|
|
171
171
|
specification_version: 4
|
172
172
|
summary: Kill any workers by memory and request counts or take custom reaction
|
173
173
|
test_files:
|
174
|
-
- spec/killer/signal_spec.rb
|
175
|
-
- spec/killer/delayed_job_spec.rb
|
176
|
-
- spec/killer/passenger_spec.rb
|
177
|
-
- spec/killer_spec.rb
|
178
|
-
- spec/count_limiter_spec.rb
|
179
|
-
- spec/worker_killer_spec.rb
|
180
|
-
- spec/support/logger.rb
|
181
174
|
- spec/middleware_spec.rb
|
175
|
+
- spec/killer_spec.rb
|
182
176
|
- spec/spec_helper.rb
|
183
177
|
- spec/delayed_job_plugin/oom_limiter_spec.rb
|
184
178
|
- spec/delayed_job_plugin/jobs_limiter_spec.rb
|
179
|
+
- spec/killer/passenger_spec.rb
|
180
|
+
- spec/killer/signal_spec.rb
|
181
|
+
- spec/killer/delayed_job_spec.rb
|
185
182
|
- spec/memory_limiter_spec.rb
|
183
|
+
- spec/support/logger.rb
|
184
|
+
- spec/worker_killer_spec.rb
|
185
|
+
- spec/count_limiter_spec.rb
|