unicorn_wrangler 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 54d7b9a72c24b04921b1166ba43b368c42165a2e
4
- data.tar.gz: df7a4c53a340a8399f0463a71f35be907d0b6785
3
+ metadata.gz: 1f72e32d0f738e4a21905f59649fde3906f7fb69
4
+ data.tar.gz: bd03778e2a04de0023ca93e5ad84b9a7a5f64c47
5
5
  SHA512:
6
- metadata.gz: 9890df840242eddf6cb7e4f7843240436cfc0b9eef194f40ac35b9f42d42b24966a9c57e6cedd34d09d6d38dc5dab0839a9410e750a86658a12bbc34f81b0e74
7
- data.tar.gz: 2089a8b26d54f74e90bafaf1cffe558c5290c835460765b06ed1abcb19eae935f43d49a683344729b76ac6b2e59501c52283121b50be8c3cf963901a158841ac
6
+ metadata.gz: 25e32ab650825a5c57bd71bda348ca6178945d4828c6e2cfcc839f6c2b0d299b8197d2c2b98a688e1fefcd4e80d7ffd8df1bb2f6f2e07b30cf3e6653d19675d6
7
+ data.tar.gz: a33421c807480547c3508fdbcff4e03e87b46a15e20735146194b16a087cb664b4bdaa635f357523409de7c64dce8434fbaa9ea51366421e929c9467a9f1049d
@@ -67,7 +67,7 @@ module UnicornWrangler
67
67
  @stats.histogram("#{STATS_NAMESPACE}.kill.total_request_time", request_time)
68
68
  end
69
69
 
70
- @logger.info "Killing unicorn worker ##{Process.pid} for #{reason}. Requests: #{requests}, Time: #{request_time}, Memory: #{memory}MB"
70
+ report_status "Killing", reason, memory, requests, request_time
71
71
 
72
72
  Process.kill(:QUIT, Process.pid)
73
73
  end
@@ -76,6 +76,10 @@ module UnicornWrangler
76
76
  def used_memory
77
77
  `ps -o rss= -p #{Process.pid}`.to_i / 1024
78
78
  end
79
+
80
+ def report_status(status, reason, memory, requests, request_time)
81
+ @logger.info "#{status} unicorn worker ##{Process.pid} for #{reason}. Requests: #{requests}, Time: #{request_time}, Memory: #{memory}MB"
82
+ end
79
83
  end
80
84
 
81
85
  class OutOfMemoryKiller < Killer
@@ -88,8 +92,13 @@ module UnicornWrangler
88
92
 
89
93
  def call(requests, request_time)
90
94
  return unless (requests % @check_every).zero? # avoid overhead of checking memory too often
91
- return unless (memory = used_memory) > @max
92
- kill :memory, memory, requests, request_time
95
+ memory = used_memory
96
+ if memory > @max
97
+ kill :memory, memory, requests, request_time
98
+ else
99
+ @stats.histogram("#{STATS_NAMESPACE}.keep.memory", memory)
100
+ report_status "Keeping", :memory, memory, requests, request_time
101
+ end
93
102
  end
94
103
  end
95
104
 
@@ -1,3 +1,3 @@
1
1
  module UnicornWrangler
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unicorn_wrangler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-27 00:00:00.000000000 Z
11
+ date: 2017-02-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: michael@grosser.it