Sha256: fbf6377a2b95aedfe8144f895fc883afcde5c1fc46e1956ca82461d6c53af78b

Contents?: true

Size: 1.17 KB

Versions: 10

Compression:

Stored size: 1.17 KB

Contents

require 'slop'
require 'ring/sqa'

module Ring
class SQA

  class CLI
    attr_reader :opts

    def run
      pid = $$
      puts "Running as pid: #{pid}"
      Process.daemon if @opts.daemonize?
      SQA.new
    rescue Exception => error
      crash error
      raise
    end

    private

    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

    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

    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

  end

end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ring-sqa-0.4.3 lib/ring/sqa/cli.rb
ring-sqa-0.4.2 lib/ring/sqa/cli.rb
ring-sqa-0.4.1 lib/ring/sqa/cli.rb
ring-sqa-0.3.1 lib/ring/sqa/cli.rb
ring-sqa-0.3.0 lib/ring/sqa/cli.rb
ring-sqa-0.2.2 lib/ring/sqa/cli.rb
ring-sqa-0.2.1 lib/ring/sqa/cli.rb
ring-sqa-0.2.0 lib/ring/sqa/cli.rb
ring-sqa-0.1.12 lib/ring/sqa/cli.rb
ring-sqa-0.1.11 lib/ring/sqa/cli.rb