unicorn-worker-killer 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -6
- data/ChangeLog +6 -0
- data/VERSION +1 -1
- data/lib/unicorn/worker_killer.rb +4 -36
- data/unicorn-worker-killer.gemspec +3 -1
- metadata +26 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
5
|
-
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c797670bfc0ae3167daa7fe1182233559315ff54
|
4
|
+
data.tar.gz: 2eef704073a541d87d25d67f2db032a4ab1a4e49
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2e2ae23ab3aa77ead7054cc95142750dc48395922c357d37fb705cef2c65c325bce849dcd450b0a1ad6b6d5671014dc818d62ff3c2821858d963904e2bb76187
|
7
|
+
data.tar.gz: 571aafd204e1f2e02b782dc64d47531213f941b09737561750313e5aa4fb0f227187720ed355fc8d3eee9d3b2a089799f4609be63733b24b84032434db202722
|
data/ChangeLog
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.3
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'unicorn/configuration'
|
2
|
+
require 'get_process_mem'
|
2
3
|
|
3
4
|
module Unicorn::WorkerKiller
|
4
5
|
class << self
|
@@ -44,7 +45,7 @@ module Unicorn::WorkerKiller
|
|
44
45
|
end
|
45
46
|
|
46
47
|
def randomize(integer)
|
47
|
-
RUBY_VERSION > "1.9" ? Random.rand(integer) : rand(integer)
|
48
|
+
RUBY_VERSION > "1.9" ? Random.rand(integer.abs) : rand(integer)
|
48
49
|
end
|
49
50
|
|
50
51
|
def process_client(client)
|
@@ -54,9 +55,8 @@ module Unicorn::WorkerKiller
|
|
54
55
|
@_worker_process_start ||= Time.now
|
55
56
|
@_worker_memory_limit ||= @_worker_memory_limit_min + randomize(@_worker_memory_limit_max - @_worker_memory_limit_min + 1)
|
56
57
|
@_worker_check_count += 1
|
57
|
-
|
58
58
|
if @_worker_check_count % @_worker_check_cycle == 0
|
59
|
-
rss =
|
59
|
+
rss = GetProcessMem.new.bytes
|
60
60
|
logger.info "#{self}: worker (pid: #{Process.pid}) using #{rss} bytes." if @_verbose
|
61
61
|
if rss > @_worker_memory_limit
|
62
62
|
logger.warn "#{self}: worker (pid: #{Process.pid}) exceeds memory limit (#{rss} bytes > #{@_worker_memory_limit} bytes)"
|
@@ -65,38 +65,6 @@ module Unicorn::WorkerKiller
|
|
65
65
|
@_worker_check_count = 0
|
66
66
|
end
|
67
67
|
end
|
68
|
-
|
69
|
-
private
|
70
|
-
|
71
|
-
def _worker_rss
|
72
|
-
proc_status = "/proc/#{Process.pid}/status"
|
73
|
-
if File.exists? proc_status
|
74
|
-
open(proc_status).each_line { |l|
|
75
|
-
if l.include? 'VmRSS'
|
76
|
-
ls = l.split
|
77
|
-
if ls.length == 3
|
78
|
-
value = ls[1].to_i
|
79
|
-
unit = ls[2]
|
80
|
-
case unit.downcase
|
81
|
-
when 'kb'
|
82
|
-
return value*(1024**1)
|
83
|
-
when 'mb'
|
84
|
-
return value*(1024**2)
|
85
|
-
when 'gb'
|
86
|
-
return value*(1024**3)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
}
|
91
|
-
end
|
92
|
-
|
93
|
-
# Forking the child process sometimes fails under low memory condition.
|
94
|
-
# It would be ideal for not forking the process to get RSS. For Linux,
|
95
|
-
# this module reads '/proc/<pid>/status' to get RSS, but not for other
|
96
|
-
# environments (e.g. MacOS and Windows).
|
97
|
-
kb = `ps -o rss= -p #{Process.pid}`.to_i
|
98
|
-
return kb * 1024
|
99
|
-
end
|
100
68
|
end
|
101
69
|
|
102
70
|
module MaxRequests
|
@@ -117,7 +85,7 @@ module Unicorn::WorkerKiller
|
|
117
85
|
end
|
118
86
|
|
119
87
|
def randomize(integer)
|
120
|
-
RUBY_VERSION > "1.9" ? Random.rand(integer) : rand(integer)
|
88
|
+
RUBY_VERSION > "1.9" ? Random.rand(integer.abs) : rand(integer)
|
121
89
|
end
|
122
90
|
|
123
91
|
def process_client(client)
|
@@ -14,7 +14,9 @@ Gem::Specification.new do |gem|
|
|
14
14
|
gem.files = `git ls-files`.split("\n")
|
15
15
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
16
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
gem.licenses = ["GPLv2+", "Ruby 1.8"]
|
17
18
|
gem.require_paths = ['lib']
|
18
|
-
gem.add_dependency "unicorn",
|
19
|
+
gem.add_dependency "unicorn", "~> 4"
|
20
|
+
gem.add_dependency "get_process_mem", "~> 0"
|
19
21
|
gem.add_development_dependency "rake", ">= 0.9.2"
|
20
22
|
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.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kazuki Ohta
|
@@ -10,34 +10,48 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2014-12-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: unicorn
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
|
-
- - ~>
|
19
|
+
- - "~>"
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: '4'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
|
-
- - ~>
|
26
|
+
- - "~>"
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: '4'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: get_process_mem
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - "~>"
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
type: :runtime
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
29
43
|
- !ruby/object:Gem::Dependency
|
30
44
|
name: rake
|
31
45
|
requirement: !ruby/object:Gem::Requirement
|
32
46
|
requirements:
|
33
|
-
- -
|
47
|
+
- - ">="
|
34
48
|
- !ruby/object:Gem::Version
|
35
49
|
version: 0.9.2
|
36
50
|
type: :development
|
37
51
|
prerelease: false
|
38
52
|
version_requirements: !ruby/object:Gem::Requirement
|
39
53
|
requirements:
|
40
|
-
- -
|
54
|
+
- - ">="
|
41
55
|
- !ruby/object:Gem::Version
|
42
56
|
version: 0.9.2
|
43
57
|
description: Kill unicorn workers by memory and request counts
|
@@ -60,7 +74,9 @@ files:
|
|
60
74
|
- lib/unicorn/worker_killer.rb
|
61
75
|
- unicorn-worker-killer.gemspec
|
62
76
|
homepage: https://github.com/kzk/unicorn-worker-killer
|
63
|
-
licenses:
|
77
|
+
licenses:
|
78
|
+
- GPLv2+
|
79
|
+
- Ruby 1.8
|
64
80
|
metadata: {}
|
65
81
|
post_install_message:
|
66
82
|
rdoc_options: []
|
@@ -68,17 +84,17 @@ require_paths:
|
|
68
84
|
- lib
|
69
85
|
required_ruby_version: !ruby/object:Gem::Requirement
|
70
86
|
requirements:
|
71
|
-
- -
|
87
|
+
- - ">="
|
72
88
|
- !ruby/object:Gem::Version
|
73
89
|
version: '0'
|
74
90
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
91
|
requirements:
|
76
|
-
- -
|
92
|
+
- - ">="
|
77
93
|
- !ruby/object:Gem::Version
|
78
94
|
version: '0'
|
79
95
|
requirements: []
|
80
96
|
rubyforge_project:
|
81
|
-
rubygems_version: 2.
|
97
|
+
rubygems_version: 2.2.2
|
82
98
|
signing_key:
|
83
99
|
specification_version: 4
|
84
100
|
summary: Kill unicorn workers by memory and request counts
|