Sha256: 9f4d702c3400808863cbea715664e88f61f30582603be08e14ae285f0a6a9bcf

Contents?: true

Size: 976 Bytes

Versions: 12

Compression:

Stored size: 976 Bytes

Contents

module Oxidized
  class CLI
    require 'oxidized'
    require 'slop'

    def run
      Process.daemon if @opts[:daemonize]
      begin
        Oxidized.new
      rescue => error
        crash error
        raise
      end
    end

    private

    def initialize
      Log.info "Oxidized starting, running as pid #{$$}"
      _args, @opts = parse_opts
      CFG.debug = true if @opts[:debug]
    end

    def crash error
      Log.fatal "Oxidized crashed, crashfile written in #{Config::Crash}"
      open Config::Crash, 'w' do |file|
        file.puts '-' * 50
        file.puts Time.now.utc
        file.puts error.message + ' [' + error.class.to_s + ']'
        file.puts '-' * 50
        file.puts error.backtrace
        file.puts '-' * 50
      end
    end

    def parse_opts
      opts = Slop.new(:help=>true) do
        on 'd', 'debug', 'turn on debugging'
        on 'daemonize',  'Daemonize/fork the process'
      end
      [opts.parse!, opts]
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
oxidized-0.9.0 lib/oxidized/cli.rb
oxidized-0.8.1 lib/oxidized/cli.rb
oxidized-0.8.0 lib/oxidized/cli.rb
oxidized-0.7.2 lib/oxidized/cli.rb
oxidized-0.7.1 lib/oxidized/cli.rb
oxidized-0.7.0 lib/oxidized/cli.rb
oxidized-0.6.0 lib/oxidized/cli.rb
oxidized-0.5.0 lib/oxidized/cli.rb
oxidized-0.4.1 lib/oxidized/cli.rb
oxidized-0.4.0 lib/oxidized/cli.rb
oxidized-0.3.0 lib/oxidized/cli.rb
oxidized-0.2.4 lib/oxidized/cli.rb