module SubZero::Main
Attributes
cli_args[RW]
config[RW]
Public Instance Methods
boot(cli_args)
click to toggle source
# File lib/sub_zero/main.rb, line 10 def boot cli_args log "booting..." log "\tloading service.yml" @config = load_config log "\tparsing CLI args" @cli_args = parse_cli_args cli_args self end
Private Instance Methods
load_config()
click to toggle source
# File lib/sub_zero/main.rb, line 54 def load_config begin YAML.load_file('config/service.yml')[env] rescue => ex log "could not load config file! (#{ex.message})", 'ERROR' exit 1 end end
parse_cli_args(args)
click to toggle source
# File lib/sub_zero/main.rb, line 33 def parse_cli_args args opts = {} port = @config['service']['broker_port'] pid_path = log_path = File.join( File.dirname(__FILE__), '..') loop { case ARGV[0] when '-p' then ARGV.shift; port = ARGV.shift when '-l' then ARGV.shift; log_path = ARGV.shift when '-pp' then ARGV.shift; pid_path = ARGV.shift when /^-/ then usage("Unknown option: #{ARGV[0].inspect}") else break end; } opts[:port] = port opts[:log_path] = log_path opts[:pid_path] = pid_path opts end
usage(s)
click to toggle source
# File lib/sub_zero/main.rb, line 26 def usage(s) $stderr.puts "<%= name %> v#{SubZero::VERSION}" # change to const for the service! $stderr.puts s $stderr.puts "Usage: #{File.basename($0)}: [-p port] [-l log_path] [-pp pid_path]" exit(1) end