lib/golden_brindle/cluster.rb in golden_brindle-0.0.3 vs lib/golden_brindle/cluster.rb in golden_brindle-0.0.4

- old
+ new

@@ -9,24 +9,36 @@ ["-c", "--conf_path PATH", "Path to golden_brindle configuration files", :@cwd, "."], ["-V", "", "Verbose output", :@verbose, false] ] end + def validate + @cwd = File.expand_path(@cwd) + valid_dir? @cwd, "Invalid path to golden_brindle configuration files: #@cwd" + return @valid + end + def run command = self.class.to_s.downcase.split('::')[1] + counter = 0 + errors = 0 Dir.chdir @cwd do confs = Dir.glob("*.yml") confs += Dir.glob("*.conf") confs.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 - puts "golden_brindle #{command} returned an error." unless $?.success? + status = $?.success? + puts "golden_brindle #{command} returned an error." unless status + counter += 1 if status + errors += 1 unless status end end + puts "Success:#{counter}; Errors: #{errors}" end end class Start < GemPlugin::Plugin "/commands" @@ -40,6 +52,6 @@ class Restart < GemPlugin::Plugin "/commands" include Cluster::Base end -end \ No newline at end of file +end