Sha256: f827f38ef5b38057918ba985f88fc70a6ea80191d24c542ed51ae129c9f95f05

Contents?: true

Size: 917 Bytes

Versions: 2

Compression:

Stored size: 917 Bytes

Contents

#!/usr/bin/env ruby

$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])

require 'optparse'
require 'proxymachine'

begin
  options = {:host => "0.0.0.0", :port => 5432}

  opts = OptionParser.new do |opts|
    opts.banner = <<-EOF
  Usage:
    proxymachine -c <config file> [-h <host>] [-p <port>]

  Options:
EOF

    opts.on("-cCONFIG", "--config CONFIG", "Configuration file") do |x|
      options[:config] = x
    end

    opts.on("-hHOST", "--host HOST", "Hostname to bind. Default 0.0.0.0") do |x|
      options[:host] = x
    end

    opts.on("-pPORT", "--port PORT", "Port to listen on. Default 5432") do |x|
      options[:host] = x
    end
  end

  opts.parse!

  load(options[:config])
  ProxyMachine.run(options[:host], options[:port])
rescue Exception => e
  if e.instance_of?(SystemExit)
    raise
  else
    puts 'Uncaught exception'
    puts e.message
    puts e.backtrace.join("\n")
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mojombo-proxymachine-0.1.0 bin/proxymachine
mojombo-proxymachine-0.1.1 bin/proxymachine