Display application 'uptime' in API status endpoint

This commit is contained in:
Scott Schneider 2015-02-04 12:56:59 -08:00
parent 79af9c9fd4
commit 49b01a8e00

View file

@ -5,6 +5,8 @@ module Vmpooler
config_file = File.expand_path('vmpooler.yaml')
$config = YAML.load_file(config_file)
$config[:uptime] = Time.now
# Set some defaults
$config[:redis] ||= Hash.new
$config[:redis]['server'] ||= 'localhost'
@ -201,6 +203,8 @@ module Vmpooler
result['clone_average'] = $redis.hvals('vmpooler__clone__'+Date.today.to_s).map( &:to_f ).reduce( :+ ) / result['clone_total']
end
result['uptime'] = Time.now - $config[:uptime]
JSON.pretty_generate(Hash[result.sort_by{|k,v| k}])
end