Class: TyrantManager::Commands::Start

Inherits:
TyrantManager::Command show all
Defined in:
lib/tyrant_manager/commands/start.rb

Overview

Start one ore more instances

Instance Attribute Summary

Attributes inherited from TyrantManager::Command

#manager, #options

Instance Method Summary collapse

Methods inherited from TyrantManager::Command

#after, #before, #command_name, command_name, #error, find, inherited, #initialize, list, #logger

Constructor Details

This class inherits a constructor from TyrantManager::Command

Instance Method Details

#runObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/tyrant_manager/commands/start.rb', line 8

def run
  manager.each_instance do |instance|
    ilist = options['instances']
    if ilist  == %w[ all ] or ilist.include?( instance.name ) then
      parts = [ "Starting #{instance.name}" ]
      parts << instance.start_command

      if options['dry-run'] then
        parts << "(dry-run)"
        logger.info parts.join(" : ")

      elsif not instance.running? then
        logger.info parts.join(" : ")
        Dir.chdir( instance.home_dir ) do
          instance.start 
        end
      else
        logger.info "Instance #{instance.name} already running"
      end
    end
  end
end