class Zold::Routines::Retire

Kill the node if it's too old.

Author

Yegor Bugayenko (yegor256@gmail.com)

Copyright

Copyright © 2018 Yegor Bugayenko

License

MIT

Public Class Methods

new(opts, log: Log::NULL) click to toggle source
# File lib/zold/commands/routines/retire.rb, line 33
def initialize(opts, log: Log::NULL)
  @opts = opts
  @log = log
  @start = Time.now
end

Public Instance Methods

exec(step = 0) click to toggle source
# File lib/zold/commands/routines/retire.rb, line 39
def exec(step = 0)
  sleep(60) unless @opts['routine-immediately']
  days = 4
  return if step < days * 24 * 60 && Time.now - @start < days * 24 * 60 * 60
  return if @opts['never-reboot']
  @log.info("We are too old, step ##{step}, it's time to retire (use --never-reboot to avoid this)")
  require_relative '../../node/front'
  Zold::Front.stop!
end