Class: Zold::Routines::Retire

Inherits:
Object
  • Object
show all
Defined in:
lib/zold/commands/routines/retire.rb

Overview

Kill the node if it’s too old.

Author

Yegor Bugayenko ([email protected])

Copyright

Copyright © 2018 Yegor Bugayenko

License

MIT

Instance Method Summary collapse

Constructor Details

#initialize(opts, log: Log::NULL) ⇒ Retire

Returns a new instance of Retire.



33
34
35
36
37
# File 'lib/zold/commands/routines/retire.rb', line 33

def initialize(opts, log: Log::NULL)
  @opts = opts
  @log = log
  @start = Time.now
end

Instance Method Details

#exec(step = 0) ⇒ Object



39
40
41
42
43
44
45
46
47
# 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