garbageman 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -1
- data/VERSION +1 -1
- data/garbageman.gemspec +1 -1
- data/lib/garbageman/collector.rb +27 -6
- data/lib/garbageman/config.rb +1 -1
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= garbageman
|
2
2
|
|
3
|
-
|
3
|
+
Rubies GC can take a long time. And while ruby is garbage collecting nothing else can happen. This is especially bad in an async environment like EventMachine where it is a single thread process. The GarbageMan disable rubies GC while processing requests. And while it is GCing it takes it self out of the nginx upstream.
|
4
4
|
|
5
5
|
== Contributing to garbageman
|
6
6
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.6
|
data/garbageman.gemspec
CHANGED
data/lib/garbageman/collector.rb
CHANGED
@@ -4,6 +4,15 @@ module GarbageMan
|
|
4
4
|
class Collector
|
5
5
|
include Singleton
|
6
6
|
|
7
|
+
module Status
|
8
|
+
SELECTED = 'selected'
|
9
|
+
WILL_COLLECT = 'will_collect'
|
10
|
+
STARTING = 'starting'
|
11
|
+
NEXT_SERVER = 'next_server'
|
12
|
+
end
|
13
|
+
|
14
|
+
include Status
|
15
|
+
|
7
16
|
attr_accessor :request_count, :will_collect
|
8
17
|
attr_reader :fiber_poll
|
9
18
|
|
@@ -23,8 +32,15 @@ module GarbageMan
|
|
23
32
|
return true
|
24
33
|
end
|
25
34
|
|
35
|
+
if select_next_server?
|
36
|
+
EM.next_tick do
|
37
|
+
select_next_server
|
38
|
+
end
|
39
|
+
return true
|
40
|
+
end
|
41
|
+
|
26
42
|
if should_collect?
|
27
|
-
write_gc_yaml server_index,
|
43
|
+
write_gc_yaml server_index, WILL_COLLECT
|
28
44
|
false
|
29
45
|
else
|
30
46
|
true
|
@@ -41,18 +57,18 @@ module GarbageMan
|
|
41
57
|
|
42
58
|
return unless can_collect?
|
43
59
|
|
44
|
-
write_gc_yaml server_index,
|
60
|
+
write_gc_yaml server_index, STARTING
|
45
61
|
debug "starting gc"
|
46
62
|
starts = Time.now
|
47
63
|
GC.enable
|
48
64
|
GC.start
|
49
65
|
diff = (Time.now - starts) * 1000
|
50
66
|
info "GC took #{'%.2f' % diff}ms"
|
51
|
-
write_gc_yaml server_index,
|
67
|
+
write_gc_yaml server_index, NEXT_SERVER
|
52
68
|
|
53
69
|
reset
|
54
70
|
|
55
|
-
if can_disable?
|
71
|
+
if can_disable?
|
56
72
|
debug "disabling gc"
|
57
73
|
GC.disable
|
58
74
|
else
|
@@ -64,7 +80,7 @@ module GarbageMan
|
|
64
80
|
def create_gc_yaml
|
65
81
|
return unless server_index
|
66
82
|
return if File.exists?(Config.gc_yaml_file)
|
67
|
-
write_gc_yaml server_index,
|
83
|
+
write_gc_yaml server_index, SELECTED
|
68
84
|
end
|
69
85
|
|
70
86
|
def logger; GarbageMan.logger; end
|
@@ -98,7 +114,7 @@ module GarbageMan
|
|
98
114
|
file = socket_file next_server_index
|
99
115
|
next unless File.exists?(file)
|
100
116
|
debug "selected #{next_server_index}"
|
101
|
-
write_gc_yaml next_server_index,
|
117
|
+
write_gc_yaml next_server_index, SELECTED
|
102
118
|
return true
|
103
119
|
end
|
104
120
|
false
|
@@ -136,6 +152,11 @@ module GarbageMan
|
|
136
152
|
config && config['gc'] && config['gc']['server'] && config['gc']['server'] == server_index
|
137
153
|
end
|
138
154
|
|
155
|
+
def select_next_server?
|
156
|
+
config = Config.gc_config
|
157
|
+
config && config['gc'] && config['gc']['server'] && config['gc']['server'] == server_index && config['gc']['status'] == 'next_server'
|
158
|
+
end
|
159
|
+
|
139
160
|
def can_disable?
|
140
161
|
Config.thin_config.has_key?('socket') && not_queuing? && min_running_servers?
|
141
162
|
end
|
data/lib/garbageman/config.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: garbageman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -102,7 +102,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
102
102
|
version: '0'
|
103
103
|
segments:
|
104
104
|
- 0
|
105
|
-
hash:
|
105
|
+
hash: 244992225797517962
|
106
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
107
|
none: false
|
108
108
|
requirements:
|