unicorn-worker-killer 0.3.6 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/AUTHORS +1 -0
- data/ChangeLog +7 -0
- data/VERSION +1 -1
- data/lib/unicorn/worker_killer.rb +18 -18
- data/unicorn-worker-killer.gemspec +2 -2
- metadata +17 -9
- checksums.yaml +0 -7
data/AUTHORS
CHANGED
data/ChangeLog
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
Release 0.4.1 - 2013/03/12
|
2
|
+
* Kill attempts happen once per request, not in a loop
|
3
|
+
|
4
|
+
Release 0.4.0 - 2013/03/12
|
5
|
+
* Send signals from inside a Thread (required for QUIT signal)
|
6
|
+
* Fix broken if/else in kill_self
|
7
|
+
|
1
8
|
Release 0.3.6 - 2013/03/09
|
2
9
|
* do not require configuration
|
3
10
|
* fix missing randomize() in MaxRequests killer
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.1
|
@@ -5,28 +5,24 @@ module Unicorn::WorkerKiller
|
|
5
5
|
attr_accessor :configuration
|
6
6
|
end
|
7
7
|
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
8
|
+
# Kill the current process by telling it to send signals to itself. If
|
9
|
+
# the process isn't killed after `configuration.max_quit` QUIT signals,
|
10
|
+
# send TERM signals until `configuration.max_term`. Finally, send a KILL
|
11
|
+
# signal. A single signal is sent per request.
|
11
12
|
# @see http://unicorn.bogomips.org/SIGNALS.html
|
12
13
|
def self.kill_self(logger, start_time)
|
13
|
-
alive_sec = (Time.now - start_time).
|
14
|
-
|
15
|
-
i = 0
|
16
|
-
while true
|
17
|
-
i += 1
|
18
|
-
sig = :QUIT
|
19
|
-
if i > configuration.max_quit
|
20
|
-
sig = :TERM
|
21
|
-
elsif i > configuration.max_term
|
22
|
-
sig = :KILL
|
23
|
-
end
|
14
|
+
alive_sec = (Time.now - start_time).round
|
15
|
+
worker_pid = Process.pid
|
24
16
|
|
25
|
-
|
26
|
-
|
17
|
+
@@kill_attempts ||= 0
|
18
|
+
@@kill_attempts += 1
|
27
19
|
|
28
|
-
|
29
|
-
|
20
|
+
sig = :QUIT
|
21
|
+
sig = :TERM if @@kill_attempts > configuration.max_quit
|
22
|
+
sig = :KILL if @@kill_attempts > configuration.max_term
|
23
|
+
|
24
|
+
logger.warn "#{self} send SIG#{sig} (pid: #{worker_pid}) alive: #{alive_sec} sec (trial #{@@kill_attempts})"
|
25
|
+
Process.kill sig, worker_pid
|
30
26
|
end
|
31
27
|
|
32
28
|
module Oom
|
@@ -52,11 +48,13 @@ module Unicorn::WorkerKiller
|
|
52
48
|
|
53
49
|
def process_client(client)
|
54
50
|
super(client) # Unicorn::HttpServer#process_client
|
51
|
+
|
55
52
|
return if @_worker_memory_limit_min == 0 && @_worker_memory_limit_max == 0
|
56
53
|
|
57
54
|
@_worker_process_start ||= Time.now
|
58
55
|
@_worker_memory_limit ||= @_worker_memory_limit_min + randomize(@_worker_memory_limit_max - @_worker_memory_limit_min + 1)
|
59
56
|
@_worker_check_count += 1
|
57
|
+
|
60
58
|
if @_worker_check_count % @_worker_check_cycle == 0
|
61
59
|
rss = _worker_rss()
|
62
60
|
if rss > @_worker_memory_limit
|
@@ -112,6 +110,7 @@ module Unicorn::WorkerKiller
|
|
112
110
|
s.instance_variable_set(:@_worker_max_requests_min, max_requests_min)
|
113
111
|
s.instance_variable_set(:@_worker_max_requests_max, max_requests_max)
|
114
112
|
end
|
113
|
+
|
115
114
|
app # pretend to be Rack middleware since it was in the past
|
116
115
|
end
|
117
116
|
|
@@ -126,6 +125,7 @@ module Unicorn::WorkerKiller
|
|
126
125
|
@_worker_process_start ||= Time.now
|
127
126
|
@_worker_cur_requests ||= @_worker_max_requests_min + randomize(@_worker_max_requests_max - @_worker_max_requests_min + 1)
|
128
127
|
@_worker_max_requests ||= @_worker_cur_requests
|
128
|
+
|
129
129
|
if (@_worker_cur_requests -= 1) <= 0
|
130
130
|
logger.warn "#{self}: worker (pid: #{Process.pid}) exceeds max number of requests (limit: #{@_worker_max_requests})"
|
131
131
|
Unicorn::WorkerKiller.kill_self(logger, @_worker_process_start)
|
@@ -7,8 +7,8 @@ Gem::Specification.new do |gem|
|
|
7
7
|
gem.homepage = "https://github.com/kzk/unicorn-worker-killer"
|
8
8
|
gem.summary = gem.description
|
9
9
|
gem.version = File.read("VERSION").strip
|
10
|
-
gem.authors = ["Kazuki Ohta", "Sadayuki Furuhashi"]
|
11
|
-
gem.email = ["kazuki.ohta@gmail.com", "frsyuki@gmail.com"]
|
10
|
+
gem.authors = ["Kazuki Ohta", "Sadayuki Furuhashi", "Jonathan Clem"]
|
11
|
+
gem.email = ["kazuki.ohta@gmail.com", "frsyuki@gmail.com", "jonathan@jclem.net"]
|
12
12
|
gem.has_rdoc = false
|
13
13
|
#gem.platform = Gem::Platform::RUBY
|
14
14
|
gem.files = `git ls-files`.split("\n")
|
metadata
CHANGED
@@ -1,19 +1,22 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unicorn-worker-killer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Kazuki Ohta
|
8
9
|
- Sadayuki Furuhashi
|
10
|
+
- Jonathan Clem
|
9
11
|
autorequire:
|
10
12
|
bindir: bin
|
11
13
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
14
|
+
date: 2013-03-15 00:00:00.000000000 Z
|
13
15
|
dependencies:
|
14
16
|
- !ruby/object:Gem::Dependency
|
15
17
|
name: unicorn
|
16
18
|
requirement: !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
17
20
|
requirements:
|
18
21
|
- - ~>
|
19
22
|
- !ruby/object:Gem::Version
|
@@ -21,6 +24,7 @@ dependencies:
|
|
21
24
|
type: :runtime
|
22
25
|
prerelease: false
|
23
26
|
version_requirements: !ruby/object:Gem::Requirement
|
27
|
+
none: false
|
24
28
|
requirements:
|
25
29
|
- - ~>
|
26
30
|
- !ruby/object:Gem::Version
|
@@ -28,21 +32,24 @@ dependencies:
|
|
28
32
|
- !ruby/object:Gem::Dependency
|
29
33
|
name: rake
|
30
34
|
requirement: !ruby/object:Gem::Requirement
|
35
|
+
none: false
|
31
36
|
requirements:
|
32
|
-
- - '>='
|
37
|
+
- - ! '>='
|
33
38
|
- !ruby/object:Gem::Version
|
34
39
|
version: 0.9.2
|
35
40
|
type: :development
|
36
41
|
prerelease: false
|
37
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
38
44
|
requirements:
|
39
|
-
- - '>='
|
45
|
+
- - ! '>='
|
40
46
|
- !ruby/object:Gem::Version
|
41
47
|
version: 0.9.2
|
42
48
|
description: Kill unicorn workers by memory and request counts
|
43
49
|
email:
|
44
50
|
- kazuki.ohta@gmail.com
|
45
51
|
- frsyuki@gmail.com
|
52
|
+
- jonathan@jclem.net
|
46
53
|
executables: []
|
47
54
|
extensions: []
|
48
55
|
extra_rdoc_files: []
|
@@ -59,25 +66,26 @@ files:
|
|
59
66
|
- unicorn-worker-killer.gemspec
|
60
67
|
homepage: https://github.com/kzk/unicorn-worker-killer
|
61
68
|
licenses: []
|
62
|
-
metadata: {}
|
63
69
|
post_install_message:
|
64
70
|
rdoc_options: []
|
65
71
|
require_paths:
|
66
72
|
- lib
|
67
73
|
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
68
75
|
requirements:
|
69
|
-
- - '>='
|
76
|
+
- - ! '>='
|
70
77
|
- !ruby/object:Gem::Version
|
71
78
|
version: '0'
|
72
79
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
73
81
|
requirements:
|
74
|
-
- - '>='
|
82
|
+
- - ! '>='
|
75
83
|
- !ruby/object:Gem::Version
|
76
84
|
version: '0'
|
77
85
|
requirements: []
|
78
86
|
rubyforge_project:
|
79
|
-
rubygems_version:
|
87
|
+
rubygems_version: 1.8.24
|
80
88
|
signing_key:
|
81
|
-
specification_version:
|
89
|
+
specification_version: 3
|
82
90
|
summary: Kill unicorn workers by memory and request counts
|
83
91
|
test_files: []
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 472f5a54002c4f7d424ef88e613bce3b8d0b6a12
|
4
|
-
data.tar.gz: 50cf272d41b6cd9bbbd9d3e2218fe189c2aac5d6
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 7a5a124e1b518ebb417abc8a14f6a93202a816973a6b69073b050072193c082d071a6f6ca418b04b15b211f80327e643cccf3534452a33286df916a2aa6050bd
|
7
|
-
data.tar.gz: 65bb35218c266c2264d90d71c641ea872eba204a6420b98173256f67454cb301ad9170099e54e4c340c66adc2e53f54fa74d98f2bc77f334339ffb57cc59fafa
|