class Ring::SQA::CLI

Attributes

opts[R]

Public Class Methods

new() click to toggle source
# File lib/ring/sqa/cli.rb, line 22
def initialize
  _args, @opts = opts_parse
  CFG.debug = @opts.debug?
  CFG.afi = @opts.ipv6? ? "ipv6" : "ipv4"
  CFG.fake  = @opts.fake?
  require_relative 'log'
  Log.level = Logger::DEBUG if @opts.debug?
  run
end

Public Instance Methods

run() click to toggle source
# File lib/ring/sqa/cli.rb, line 10
def run
  pid = $$
  puts "Running as pid: #{pid}"
  Process.daemon if @opts.daemonize?
  SQA.new
rescue Exception => error
  crash error
  raise
end

Private Instance Methods

crash(error) click to toggle source
# File lib/ring/sqa/cli.rb, line 43
def crash error
  file = File.join '/tmp', "ring-sqa-crash.txt.#{$$}"
  open file, 'w' do |file|
    file.puts error.class.to_s + ' => ' + error.message
    file.puts '-' * 70
    file.puts error.backtrace
    file.puts '-' * 70
  end
end
opts_parse() click to toggle source
# File lib/ring/sqa/cli.rb, line 32
def opts_parse
  slop = Slop.new(:help=>true) do
    banner 'Usage: ring-sqad [options]'
    on 'd', '--debug', 'turn on debugging'
    on '6', '--ipv6',  'use ipv6 instead of ipv4'
    on '--fake',       'initialize analyzebuffer with 0 nodes'
    on '--daemonize',  'run in background'
  end
  [slop.parse!, slop]
end