Class: TyrantManager::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/tyrant_manager/runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(manager, opts = {}) ⇒ Runner

Returns a new instance of Runner.



14
15
16
17
# File 'lib/tyrant_manager/runner.rb', line 14

def initialize( manager, opts = {} )
  @manager = manager
  @options = opts
end

Instance Attribute Details

#managerObject (readonly)

Returns the value of attribute manager.



12
13
14
# File 'lib/tyrant_manager/runner.rb', line 12

def manager
  @manager
end

#optionsObject (readonly)

Returns the value of attribute options.



11
12
13
# File 'lib/tyrant_manager/runner.rb', line 11

def options
  @options
end

Instance Method Details

#loggerObject



19
20
21
# File 'lib/tyrant_manager/runner.rb', line 19

def logger
  ::Logging::Logger[self]
end

#run(command_name) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/tyrant_manager/runner.rb', line 23

def run( command_name )
  cmd = Command.find( command_name ).new( self.manager, self.options )
  begin
    cmd.before
    cmd.run
  rescue => e
    logger.error "while running #{command_name} : #{e.message}"
    e.backtrace.each do |l|
      logger.warn l.strip
    end
  ensure
    cmd.after
  end
end