unicorn-worker-killer 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +4 -0
- data/VERSION +1 -1
- data/lib/unicorn/worker_killer.rb +10 -8
- metadata +2 -2
data/ChangeLog
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
@@ -15,7 +15,7 @@ module Unicorn::WorkerKiller
|
|
15
15
|
sig = :KILL
|
16
16
|
end
|
17
17
|
|
18
|
-
logger.warn "#{self} send SIGTERM (pid: #{Process.pid})
|
18
|
+
logger.warn "#{self} send SIGTERM (pid: #{Process.pid}) alive: #{alive_sec} sec (trial #{i})"
|
19
19
|
Process.kill sig, Process.pid
|
20
20
|
|
21
21
|
sleep 1 # TODO configurable sleep
|
@@ -42,14 +42,14 @@ module Unicorn::WorkerKiller
|
|
42
42
|
@_worker_process_start ||= Time.now
|
43
43
|
super(client) # Unicorn::HttpServer#process_client
|
44
44
|
|
45
|
-
|
46
|
-
if
|
47
|
-
|
48
|
-
if
|
45
|
+
@_worker_check_count += 1
|
46
|
+
if @_worker_check_count % @_worker_check_cycle == 0
|
47
|
+
rss = _worker_rss()
|
48
|
+
if rss > @_worker_memory_size
|
49
|
+
logger.warn "#{self}: worker (pid: #{Process.pid}) exceeds memory limit (#{rss} bytes > #{@_worker_memory_size} bytes)"
|
49
50
|
Unicorn::WorkerKiller.kill_self(logger, @_worker_process_start)
|
50
51
|
end
|
51
|
-
|
52
|
-
@_worker_check_count = c
|
52
|
+
@_worker_check_count = 0
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -95,6 +95,7 @@ module Unicorn::WorkerKiller
|
|
95
95
|
ObjectSpace.each_object(Unicorn::HttpServer) do |s|
|
96
96
|
s.extend(self)
|
97
97
|
s.instance_variable_set(:@_worker_max_requests, max_requests)
|
98
|
+
s.instance_variable_set(:@_worker_cur_requests, max_requests)
|
98
99
|
end
|
99
100
|
app # pretend to be Rack middleware since it was in the past
|
100
101
|
end
|
@@ -103,7 +104,8 @@ module Unicorn::WorkerKiller
|
|
103
104
|
@_worker_process_start ||= Time.now
|
104
105
|
super(client) # Unicorn::HttpServer#process_client
|
105
106
|
|
106
|
-
if (@
|
107
|
+
if (@_worker_cur_requests -= 1) <= 0
|
108
|
+
logger.warn "#{self}: worker (pid: #{Process.pid}) exceeds max number of requests (limit: #{@_worker_max_requests})"
|
107
109
|
Unicorn::WorkerKiller.kill_self(logger, @_worker_process_start)
|
108
110
|
end
|
109
111
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unicorn-worker-killer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-12-
|
13
|
+
date: 2012-12-30 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: unicorn
|