Module: Cluster::Base

Includes:
GoldenBrindle::Command::Base
Included in:
Restart, Start, Stop
Defined in:
lib/golden_brindle/cluster.rb

Instance Attribute Summary

Attributes included from GoldenBrindle::Command::Base

#done_validating, #original_args, #valid

Instance Method Summary collapse

Methods included from GoldenBrindle::Command::Base

#can_change_user?, #config_keys, #failure, #help, #initialize, #load_config, #options, #valid?, #valid_dir?, #valid_exists?, #valid_file?, #valid_group?, #valid_user?

Instance Method Details

#configureObject



7
8
9
10
11
12
# File 'lib/golden_brindle/cluster.rb', line 7

def configure 
  options [ 
    ["-c", "--conf_path PATH", "Path to golden_brindle configuration files", :@cwd, "."],
    ["-V", "", "Verbose output", :@verbose, false]
  ]
end

#runObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/golden_brindle/cluster.rb', line 20

def run
  command = self.class.to_s.downcase.split('::')[1]
  counter = 0
  errors = 0
  Dir.chdir @cwd do
    Dir.glob("**/*.{yml,conf}").each do |conf|
      cmd = "golden_brindle #{command} -C #{conf}"
      cmd += " -d" if command == "start" #daemonize only when start
      puts cmd if @verbose 
      output = `#{cmd}`
      puts output if @verbose
      status = $?.success?
      puts "golden_brindle #{command} returned an error." unless status
      status ? counter += 1 : errors += 1
    end
  end
  puts "Success:#{counter}; Errors: #{errors}"
end

#validateObject



14
15
16
17
18
# File 'lib/golden_brindle/cluster.rb', line 14

def validate
  @cwd = File.expand_path(@cwd)
  valid_dir? @cwd, "Invalid path to golden_brindle configuration files: #{@cwd}"
  @valid
end