Class: EY::Stonith::Commands::Cron

Inherits:
Abstract
  • Object
show all
Defined in:
lib/ey_stonith/commands/cron.rb

Constant Summary

Constants inherited from Abstract

Abstract::DEFAULT_CONFIG_PATH, Abstract::SCRIPT_NAME

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Abstract

#call, #command_options, #config, #execute, #history, #init_logger, #initialize, #parse!, #parser, #script

Constructor Details

This class inherits a constructor from EY::Stonith::Commands::Abstract

Class Method Details



9
10
11
# File 'lib/ey_stonith/commands/cron.rb', line 9

def self.banner
  "Run the Stonith cron-like process that invokes other stonith commands periodically"
end

.commandObject



5
6
7
# File 'lib/ey_stonith/commands/cron.rb', line 5

def self.command
  'cron'
end

Instance Method Details

#heartbeat_loop(&block) ⇒ Object



21
22
23
# File 'lib/ey_stonith/commands/cron.rb', line 21

def heartbeat_loop(&block)
  loop { config.heartbeat.ceil.times(&block) }
end

#invokeObject



13
14
15
16
17
18
19
# File 'lib/ey_stonith/commands/cron.rb', line 13

def invoke
  Stonith.logger.info "Stonith started"
  heartbeat_loop do |beat|
    unless_stopped { run_command if beat.zero? }
    sleep 1
  end
end

#run_commandObject



33
34
35
# File 'lib/ey_stonith/commands/cron.rb', line 33

def run_command
  system("#{script} check#{command_options}")
end

#unless_stoppedObject



25
26
27
28
29
30
31
# File 'lib/ey_stonith/commands/cron.rb', line 25

def unless_stopped
  if config.stop_path.exist?
    history << :stop
  else
    yield
  end
end