Sha256: 4c8de6554f8a89576f2a0a383cf4e77a8e9dcee8db8451b4ad2a21698f08106c

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

module GoldenBrindle

  module Cluster
    class Base < ::GoldenBrindle::Base
      def configure
        options [
          ["-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}"
        @valid
      end

      def run
        command = self.class.to_s.downcase.split('::').last
        counter = 0
        errors = 0
        Dir.chdir @cwd do
          Dir.glob("**/*.{yml,conf}").each do |conf|
            cmd = "golden_brindle #{command} -C #{File.join(@cwd,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
    end
  end

  module Actions
    module Cluster

      class Start < ::GoldenBrindle::Cluster::Base; end

      class Stop < ::GoldenBrindle::Cluster::Base; end

      class Restart < ::GoldenBrindle::Cluster::Base; end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
golden_brindle-0.3.2 lib/golden_brindle/actions/cluster.rb