garbageman 0.2.6 → 0.2.7
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.
- checksums.yaml +8 -8
- data/VERSION +1 -1
- data/garbageman.gemspec +6 -5
- data/lib/garbageman/collector.rb +17 -3
- data/lib/garbageman/config.rb +5 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NmM0NDc0NGU5MTVhODlkZDM5ZTkyNzE5NDI5MDk2NjFjYTRjNWRiZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MTE2NWEyYTUwMmQ3ZDI4ZmQzMWEyNmM5YWVmNzFmYjk2M2ZiNGM1ZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YmNjNzNkODUxYzJkYzQ0ODVjYzVkMjBkM2FlMDE1Y2JmZDEyNjY1OTE0NmVl
|
10
|
+
MmIzNzRjMmY3OTI3MjRjMTE3ZmJmZjQzM2RmYmY5ZGU4MjBiZjc5YzgyMGUw
|
11
|
+
MDNjMmU0ZTNmMTI1YTVlMmZhZjFmNjdmYTY5N2EwMzFkMjAxNDk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZGJjZjVlZTk2NTYxZjE5ZDA3NTQ2ZTU1YWNlZmRiMWNiZWE4Y2RhZThlNmZk
|
14
|
+
M2M1ODI1NDFmMGExMDM4YzdkMjJiYzdhYmI5ZjgyYjY4MzdiZjFiMTBmYmM2
|
15
|
+
ZWRiNzIzNjFlZDM4ZjRmNDk0YzI3ZjUyYmQ0ZThmMmM4ZjRiZjU=
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.7
|
data/garbageman.gemspec
CHANGED
@@ -2,14 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: garbageman 0.2.7 ruby lib
|
5
6
|
|
6
7
|
Gem::Specification.new do |s|
|
7
8
|
s.name = "garbageman"
|
8
|
-
s.version = "0.2.
|
9
|
+
s.version = "0.2.7"
|
9
10
|
|
10
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib"]
|
11
13
|
s.authors = ["Doug Youch"]
|
12
|
-
s.date = "
|
14
|
+
s.date = "2015-07-29"
|
13
15
|
s.description = "Disable GC while processing requests. By using nginx upstream health checks to garbage collect when no one is there."
|
14
16
|
s.email = "doug@sessionm.com"
|
15
17
|
s.extra_rdoc_files = [
|
@@ -39,12 +41,11 @@ Gem::Specification.new do |s|
|
|
39
41
|
]
|
40
42
|
s.homepage = "http://github.com/dyouch5@yahoo.com/garbageman"
|
41
43
|
s.licenses = ["MIT"]
|
42
|
-
s.
|
43
|
-
s.rubygems_version = "1.8.23"
|
44
|
+
s.rubygems_version = "2.4.6"
|
44
45
|
s.summary = "Process requests without garbage collection"
|
45
46
|
|
46
47
|
if s.respond_to? :specification_version then
|
47
|
-
s.specification_version =
|
48
|
+
s.specification_version = 4
|
48
49
|
|
49
50
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
50
51
|
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
data/lib/garbageman/collector.rb
CHANGED
@@ -20,12 +20,13 @@ module GarbageMan
|
|
20
20
|
WAITED_TOO_LONG = "waited %.2f seconds to gc"
|
21
21
|
DISABLE_GC = "disabling gc"
|
22
22
|
CANT_TURN_OFF = "enabling gc, can not turn off"
|
23
|
+
CONNECTIONS_DID_NOT_DRAIN_IN_TIME = 'connections did not drain in time'
|
23
24
|
end
|
24
25
|
|
25
26
|
include Messages
|
26
27
|
|
27
28
|
attr_accessor :request_count, :will_collect, :will_select_next_server, :show_gc_times
|
28
|
-
attr_reader :fiber_poll, :last_gc_finished_at, :before_gc_callbacks, :after_gc_callbacks
|
29
|
+
attr_reader :fiber_poll, :last_gc_finished_at, :before_gc_callbacks, :after_gc_callbacks, :selected_to_collect_at
|
29
30
|
|
30
31
|
def initialize
|
31
32
|
@show_gc_times = true
|
@@ -57,6 +58,7 @@ module GarbageMan
|
|
57
58
|
end
|
58
59
|
|
59
60
|
if should_collect?
|
61
|
+
@selected_to_collect_at ||= Time.now
|
60
62
|
write_gc_yaml server_index, WILL_COLLECT
|
61
63
|
false
|
62
64
|
else
|
@@ -74,8 +76,15 @@ module GarbageMan
|
|
74
76
|
GC.enable
|
75
77
|
end
|
76
78
|
|
77
|
-
|
78
|
-
|
79
|
+
unless can_collect?
|
80
|
+
return unless will_collect # return unless been selected to gc
|
81
|
+
if waited_too_long_for_connections_to_drain?
|
82
|
+
warn CONNECTIONS_DID_NOT_DRAIN_IN_TIME
|
83
|
+
else
|
84
|
+
return
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
79
88
|
before_gc_callbacks.each(&:call)
|
80
89
|
|
81
90
|
write_gc_yaml server_index, STARTING
|
@@ -159,6 +168,7 @@ module GarbageMan
|
|
159
168
|
@request_count = 0
|
160
169
|
@will_collect = false
|
161
170
|
@will_select_next_server = false
|
171
|
+
@selected_to_collect_at = nil
|
162
172
|
end
|
163
173
|
|
164
174
|
def busy?
|
@@ -233,6 +243,10 @@ module GarbageMan
|
|
233
243
|
return false unless @last_gc_finished_at
|
234
244
|
(Time.now - @last_gc_finished_at) >= Config.max_time_without_gc
|
235
245
|
end
|
246
|
+
|
247
|
+
def waited_too_long_for_connections_to_drain?
|
248
|
+
@selected_to_collect_at && (Time.now - @selected_to_collect_at) >= Config.max_connection_drain_time
|
249
|
+
end
|
236
250
|
end
|
237
251
|
end
|
238
252
|
|
data/lib/garbageman/config.rb
CHANGED
@@ -47,5 +47,10 @@ module GarbageMan
|
|
47
47
|
@@max_time_without_gc = 60
|
48
48
|
def self.max_time_without_gc; @@max_time_without_gc; end
|
49
49
|
def self.max_time_without_gc=(time); @@max_time_without_gc = time; end
|
50
|
+
|
51
|
+
# max time to wait for connections to drain
|
52
|
+
@@max_connection_drain_time = 60
|
53
|
+
def self.max_connection_drain_time; @@max_connection_drain_time; end
|
54
|
+
def self.max_connection_drain_time=(time); @@max_connection_drain_time = time; end
|
50
55
|
end
|
51
56
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: garbageman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Doug Youch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdoc
|
@@ -100,8 +100,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
100
|
version: '0'
|
101
101
|
requirements: []
|
102
102
|
rubyforge_project:
|
103
|
-
rubygems_version: 2.
|
103
|
+
rubygems_version: 2.4.6
|
104
104
|
signing_key:
|
105
|
-
specification_version:
|
105
|
+
specification_version: 4
|
106
106
|
summary: Process requests without garbage collection
|
107
107
|
test_files: []
|