garbageman 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.7
1
+ 0.1.8
data/garbageman.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "garbageman"
8
- s.version = "0.1.7"
8
+ s.version = "0.1.8"
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"]
@@ -13,7 +13,7 @@ module GarbageMan
13
13
 
14
14
  include Status
15
15
 
16
- attr_accessor :request_count, :will_collect
16
+ attr_accessor :request_count, :will_collect, :will_select_next_server
17
17
  attr_reader :fiber_poll
18
18
 
19
19
  def initialize
@@ -33,8 +33,11 @@ module GarbageMan
33
33
  end
34
34
 
35
35
  if select_next_server?
36
- EM.next_tick do
36
+ if @will_select_next_server
37
37
  select_next_server
38
+ else
39
+ # wait until we receive another request before selecting the next server
40
+ @will_select_next_server = true
38
41
  end
39
42
  return true
40
43
  end
@@ -109,6 +112,9 @@ module GarbageMan
109
112
  end
110
113
 
111
114
  def select_next_server
115
+ return unless @will_select_next_server
116
+ @will_select_next_server = false
117
+
112
118
  Config.thin_config['servers'].times do |i|
113
119
  next_server_index = (server_index + i + 1) % num_servers
114
120
  file = socket_file next_server_index
@@ -123,6 +129,7 @@ module GarbageMan
123
129
  def reset
124
130
  @request_count = 0
125
131
  @will_collect = false
132
+ @will_select_next_server = false
126
133
  end
127
134
 
128
135
  def busy?
@@ -19,6 +19,6 @@ module GarbageMan
19
19
  def self.thin_config; @@thin_config ||= YAML.load_file("./config/thin.yml"); end
20
20
 
21
21
  def self.num_request_before_collecting; 10; end
22
- def self.min_servers_to_disable_gc; 3; end
22
+ def self.min_servers_to_disable_gc; 2; end
23
23
  end
24
24
  end
@@ -15,6 +15,7 @@ module GarbageMan
15
15
  else
16
16
  # this is not 100% preventable with nginx, nginx will still send requests while waiting for the health check response
17
17
  GarbageMan::Collector.instance.logger.debug("still receiving traffic even though I'm waiting to GC") if GarbageMan::Collector.instance.will_collect
18
+ GarbageMan::Collector.instance.select_next_server if GarbageMan::Collector::instance.will_select_next_server
18
19
  @app.call(env)
19
20
  end
20
21
  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.1.7
4
+ version: 0.1.8
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: 934671664126256271
105
+ hash: 1250881766983274641
106
106
  required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  none: false
108
108
  requirements: