lib/zold/node/front.rb in zold-0.20.1 vs lib/zold/node/front.rb in zold-0.20.2
- old
+ new
@@ -46,11 +46,11 @@
# Copyright:: Copyright (c) 2018 Yegor Bugayenko
# License:: MIT
module Zold
# Web front
class Front < Sinatra::Base
- # The minimum score required in order to recongnize a requestor
+ # The minimum score required in order to recognize a requester
# as a valuable node and add it to the list of remotes.
MIN_SCORE = 4
configure do
Thread.current.name = 'sinatra'
@@ -206,21 +206,23 @@
pid: Process.pid,
processes: processes_count,
cpus: settings.zache.get(:cpus) do
Concurrent.processor_count
end,
- memory: settings.zache.get(:memory, lifetime: 5 * 60) do
+ memory: settings.zache.get(:memory, lifetime: settings.opts['no-cache'] ? 0 : 60) do
mem = GetProcessMem.new.bytes.to_i
if mem > settings.opts['oom-limit'] * 1024 * 1024 &&
!settings.opts['skip-oom'] && !settings.opts['never-reboot']
- settings.log.error("We are too big in memory (#{Size.new(mem)}), quitting; use --skip-oom to never quit")
+ settings.log.error("We are too big in memory (#{Size.new(mem)}), quitting; \
+use --skip-oom to never quit or --memory-dump to print the entire memory usage summary on exit; \
+this is not a normal behavior, you may want to report a bug to our GitHub repository")
Front.stop!
end
mem
end,
platform: RUBY_PLATFORM,
- load: settings.zache.get(:load, lifetime: 5 * 60) do
+ load: settings.zache.get(:load, lifetime: settings.opts['no-cache'] ? 0 : 60) do
require 'usagewatch_ext'
Object.const_defined?('Usagewatch') ? Usagewatch.uw_load.to_f : 0.0
end,
threads: "#{Thread.list.select { |t| t.status == 'run' }.count}/#{Thread.list.count}",
wallets: total_wallets,
@@ -246,11 +248,11 @@
mtime: wallet.mtime.utc.iso8601,
size: wallet.size,
digest: wallet.digest,
copies: Copies.new(File.join(settings.copies, wallet.id)).all.count,
balance: wallet.balance.to_i,
- body: File.new(wallet.path).read
+ body: IO.read(wallet.path)
)
end
end
get %r{/wallet/(?<id>[A-Fa-f0-9]{16}).json} do
@@ -458,9 +460,10 @@
return unless header
yield header
end
def total_wallets
+ return 256 unless settings.opts['no-cache']
settings.zache.get(:wallets, lifetime: settings.opts['no-cache'] ? 0 : 60) do
settings.wallets.count
end
end