lib/zold/node/farm.rb in zold-0.14.43 vs lib/zold/node/farm.rb in zold-0.14.44
- old
+ new
@@ -22,10 +22,11 @@
require 'time'
require 'open3'
require_relative '../log'
require_relative '../score'
+require_relative '../age'
require_relative '../verbose_thread'
require_relative '../backtrace'
require_relative '../atomic_file'
# The farm of scores.
@@ -116,28 +117,28 @@
ensure
@log.info("Terminating the farm with #{@threads.count} threads...")
start = Time.now
finish(@cleanup)
@threads.each { |t| finish(t) }
- @log.info("Farm stopped in #{(Time.now - start).round(2)}s")
+ @log.info("Farm stopped in #{Age.new(start)}")
end
end
private
def finish(thread)
start = Time.now
@alive = false
@log.info("Attempting to terminate the thread \"#{thread.name}\"...")
loop do
- delay = (Time.now - start).round(2)
+ delay = Time.now - start
if thread.join(0.1)
- @log.info("Thread \"#{thread.name}\" finished in #{delay}s")
+ @log.info("Thread \"#{thread.name}\" finished in #{Age.new(start)}")
break
end
if delay > 10
thread.exit
- @log.error("Thread \"#{thread.name}\" forcefully terminated after #{delay}s")
+ @log.error("Thread \"#{thread.name}\" forcefully terminated after #{Age.new(start)}")
end
end
end
def cleanup(host, port, strength, threads)