lib/zold/node/front.rb in zold-0.16.13 vs lib/zold/node/front.rb in zold-0.16.14
- old
+ new
@@ -27,10 +27,11 @@
require 'json'
require 'sinatra/base'
require 'concurrent'
require 'backtrace'
require 'zache'
+require 'posix/spawn'
require_relative '../version'
require_relative '../size'
require_relative '../wallet'
require_relative '../age'
require_relative '../copies'
@@ -141,10 +142,15 @@
get '/version' do
content_type('text/plain')
settings.version
end
+ get '/protocol' do
+ content_type('text/plain')
+ settings.protocol.to_s
+ end
+
get '/pid' do
content_type('text/plain')
Process.pid.to_s
end
@@ -403,11 +409,11 @@
].flatten.join("\n\n")
end
get '/ps' do
content_type('text/plain')
- `ps ax | grep zold`
+ processes.join("\n")
end
not_found do
status(404)
content_type('text/plain')
@@ -453,11 +459,15 @@
end
end
def processes_count
settings.zache.get(:processes, lifetime: settings.network == Wallet::MAIN_NETWORK ? 60 : 0) do
- `ps ax | grep zold | wc -l`
+ processes.count
end
+ end
+
+ def processes
+ POSIX::Spawn::Child.new('ps', 'ax').out.split("\n").select { |t| t.include?('zold') }
end
def score
settings.zache.get(:score, lifetime: settings.network == Wallet::MAIN_NETWORK ? 60 : 0) do
b = settings.farm.best