Sha256: 7f0e05744711bc722d32f6731f40bea5426183321d7b06e0c770e9860e6c0777

Contents?: true

Size: 1.42 KB

Versions: 21

Compression:

Stored size: 1.42 KB

Contents

#!/usr/bin/env ruby
$LOAD_PATH << 'lib'
require 'clusterlb'
require 'colorize'
require 'getoptlong'

include Clusterlb

def display_help
	@node=nil
	@mode=nil

	puts
  puts "Nginx tool"
	puts "VERSION:        #{Clusterlb::VERSION}".colorize(:light_blue)
	puts "CONFIG:         #{Clusterlb.config_file}".colorize(:light_blue)
	puts "CLUSTERLB_HOME: #{ENV['CLUSTERLB_HOME']}".colorize(:light_blue)
	puts
	puts "Options:"
	puts "-h or --help ".ljust(30) 		  	+ "-> Display this help message"
	puts "-a or --action".ljust(30)       + "-> Action to preform (test|stop|start|reload|restart)"
	puts "-n or --node".ljust(30)      		+ "-> Apply Action to ONLY ONE NODE, if omitted actions apply to all Nodes"
	puts "-l or --list".ljust(30)      		+ "-> List Nodes"
	puts
	exit
end

def parse_cli
  opts = GetoptLong.new(
    ["-h", "--help", GetoptLong::NO_ARGUMENT],
    ["-a", "--action", GetoptLong::REQUIRED_ARGUMENT],
		["-n", "--node", GetoptLong::REQUIRED_ARGUMENT],
		["-l", "--list", GetoptLong::NO_ARGUMENT]
  )

  opts.each do |opt, arg|
    case opt
    when  "-h" || "--help"
      display_help; exit;
		when "-a" || "--action"
			@mode = arg.strip().downcase();
		when "-n" || "--node"
			@node = arg.strip().downcase();
		when "-l" || "--list"
			puts Clusterlb.list_lbs; exit
    end
  end

end

parse_cli

if @mode.nil? && @node.nil?
	display_help
	exit 1
elsif @node.nil?
	Clusterlb.cmd_nginx(@mode,"all")
else
	Clusterlb.cmd_nginx(@mode,@node)
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
clusterlb-0.1.32 exe/clusterlb-nginx
clusterlb-0.1.31 exe/clusterlb-nginx
clusterlb-0.1.30 exe/clusterlb-nginx
clusterlb-0.1.29 exe/clusterlb-nginx
clusterlb-0.1.28 exe/clusterlb-nginx
clusterlb-0.1.27 exe/clusterlb-nginx
clusterlb-0.1.26 exe/clusterlb-nginx
clusterlb-0.1.25 exe/clusterlb-nginx
clusterlb-0.1.24 exe/clusterlb-nginx
clusterlb-0.1.23 exe/clusterlb-nginx
clusterlb-0.1.22 exe/clusterlb-nginx
clusterlb-0.1.21 exe/clusterlb-nginx
clusterlb-0.1.20 exe/clusterlb-nginx
clusterlb-0.1.19 exe/clusterlb-nginx
clusterlb-0.1.17 exe/clusterlb-nginx
clusterlb-0.1.16 exe/clusterlb-nginx
clusterlb-0.1.15 exe/clusterlb-nginx
clusterlb-0.1.14 exe/clusterlb-nginx
clusterlb-0.1.13 exe/clusterlb-nginx
clusterlb-0.1.12 exe/clusterlb-nginx