garbageman 0.1.21 → 0.2.0
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/VERSION +1 -1
- data/garbageman.gemspec +2 -2
- data/lib/garbageman/collector.rb +8 -2
- data/lib/garbageman/config.rb +5 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/garbageman.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "garbageman"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Doug Youch"]
|
12
|
-
s.date = "
|
12
|
+
s.date = "2014-02-20"
|
13
13
|
s.description = "Disable GC while processing requests. By using nginx upstream health checks to garbage collect when no one is there."
|
14
14
|
s.email = "doug@sessionm.com"
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/garbageman/collector.rb
CHANGED
@@ -25,10 +25,12 @@ module GarbageMan
|
|
25
25
|
include Messages
|
26
26
|
|
27
27
|
attr_accessor :request_count, :will_collect, :will_select_next_server, :show_gc_times
|
28
|
-
attr_reader :fiber_poll, :last_gc_finished_at
|
28
|
+
attr_reader :fiber_poll, :last_gc_finished_at, :before_gc_callbacks, :after_gc_callbacks
|
29
29
|
|
30
30
|
def initialize
|
31
31
|
@show_gc_times = true
|
32
|
+
@before_gc_callbacks = []
|
33
|
+
@after_gc_callbacks = []
|
32
34
|
reset
|
33
35
|
end
|
34
36
|
|
@@ -64,7 +66,7 @@ module GarbageMan
|
|
64
66
|
|
65
67
|
def collect
|
66
68
|
# if we are starting to queue requests turn on gc, we could be in trouble
|
67
|
-
if queuing?
|
69
|
+
if Config.check_request_queue? && queuing?
|
68
70
|
debug QUEUING_REQUESTS
|
69
71
|
GC.enable
|
70
72
|
elsif waited_too_long_to_gc?
|
@@ -74,6 +76,8 @@ module GarbageMan
|
|
74
76
|
|
75
77
|
return unless can_collect?
|
76
78
|
|
79
|
+
before_gc_callbacks.each(&:call)
|
80
|
+
|
77
81
|
write_gc_yaml server_index, STARTING
|
78
82
|
debug "starting gc"
|
79
83
|
starts = Time.now
|
@@ -84,6 +88,8 @@ module GarbageMan
|
|
84
88
|
info "GC took #{'%.2f' % diff}ms for #{@request_count} requests" if @show_gc_times
|
85
89
|
write_gc_yaml server_index, NEXT_SERVER
|
86
90
|
|
91
|
+
after_gc_callbacks.each(&:call)
|
92
|
+
|
87
93
|
reset
|
88
94
|
|
89
95
|
if can_disable?
|
data/lib/garbageman/config.rb
CHANGED
@@ -29,6 +29,11 @@ module GarbageMan
|
|
29
29
|
def self.num_request_before_collecting; @@num_request_before_collecting ||= 40; end
|
30
30
|
def self.num_request_before_collecting=(val); @@num_request_before_collecting = val; end
|
31
31
|
|
32
|
+
# can configure to turn on gc if server starts queuing requests
|
33
|
+
@@check_request_queue = false
|
34
|
+
def self.check_request_queue?; @@check_request_queue; end
|
35
|
+
def self.check_request_queue=(val); @@check_request_queue = val; end
|
36
|
+
|
32
37
|
# absolutely make sure we are in the pool again before selecting next server
|
33
38
|
def self.num_request_before_selecting_next_server; 10; end
|
34
39
|
def self.min_servers_to_disable_gc; 3; end
|
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.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-02-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rdoc
|
@@ -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: -2240400875716570174
|
106
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
107
|
none: false
|
108
108
|
requirements:
|