zold 0.14.24 → 0.14.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zold/node/front.rb +1 -1
- data/lib/zold/remotes.rb +15 -11
- data/lib/zold/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b9ff618493d8f11a6c1afde18902fd7a314646f
|
4
|
+
data.tar.gz: f71b0e5dfc59c87984577c4b89177b67553d67ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '038d20d582f5367e772aa240812a5bf4367417bf350417bec4d2cc206005ff128f77acb64aa1a2fe43c31ce9621b4639be0cbb43eedb2977ff0140628893eea8'
|
7
|
+
data.tar.gz: c868c40269b7cb3504acb629ef40f7b24c3cd17ca9e2341ecaa0d1b2d61ce52fc031ddbac868b86c2abfae4dba03756d73141bbf411fa1bde044bb1cc6d4adcc
|
data/lib/zold/node/front.rb
CHANGED
@@ -155,7 +155,7 @@ while #{settings.address} is in '#{settings.network}'"
|
|
155
155
|
score: score.to_h,
|
156
156
|
pid: Process.pid,
|
157
157
|
cpus: Concurrent.processor_count,
|
158
|
-
memory: GetProcessMem.new.
|
158
|
+
memory: GetProcessMem.new.bytes,
|
159
159
|
platform: RUBY_PLATFORM,
|
160
160
|
uptime: `uptime`.strip,
|
161
161
|
threads: "#{Thread.list.select { |t| t.status == 'run' }.count}/#{Thread.list.count}",
|
data/lib/zold/remotes.rb
CHANGED
@@ -112,14 +112,16 @@ module Zold
|
|
112
112
|
end
|
113
113
|
|
114
114
|
def all
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
115
|
+
@mutex.synchronize do
|
116
|
+
list = load
|
117
|
+
max_score = list.map { |r| r[:score] }.max || 0
|
118
|
+
max_score = 1 if max_score.zero?
|
119
|
+
max_errors = list.map { |r| r[:errors] }.max || 0
|
120
|
+
max_errors = 1 if max_errors.zero?
|
121
|
+
list.sort_by do |r|
|
122
|
+
(1 - r[:errors] / max_errors) * 5 + (r[:score] / max_score)
|
123
|
+
end.reverse
|
124
|
+
end
|
123
125
|
end
|
124
126
|
|
125
127
|
def clean
|
@@ -206,9 +208,11 @@ in #{(Time.now - start).round}s; errors=#{errors}")
|
|
206
208
|
raise 'Host can\'t be nil' if host.nil?
|
207
209
|
raise 'Port can\'t be nil' if port.nil?
|
208
210
|
raise 'Port has to be of type Integer' unless port.is_a?(Integer)
|
209
|
-
|
210
|
-
|
211
|
-
|
211
|
+
@mutex.synchronize do
|
212
|
+
list = load
|
213
|
+
raise "#{host}:#{port} is absent among #{list.count} remotes" unless exists?(host, port)
|
214
|
+
list.find { |r| r[:host] == host.downcase && r[:port] == port }[:errors]
|
215
|
+
end
|
212
216
|
end
|
213
217
|
|
214
218
|
def error(host, port = Remotes::PORT)
|
data/lib/zold/version.rb
CHANGED