Sha256: 81c7fb75de63b0b1da42f47786095bc13fcdaf31b691a45d47c6a2f1d37a397d

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

#!/usr/bin/env jruby

$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), '../lib')))

require 'rubygems'
require 'kipatra'
require 'optparse'

options = {:udp => [], :tcp => [], :sipatra => false, :example => false}
option_parser = OptionParser.new do |opts|

  opts.on("-u UDP","--udp UDP") do |udp|
    host, port = udp.split(':')
    port = port.nil? ? 5060 : port.to_i
    options[:udp] << {:host => host, :port => port}
  end

  opts.on("-t TCP","--tcp TCP") do |tcp|
    host, port = tcp.split(':')
    port = port.nil? ? 5060 : port.to_i
    options[:tcp] << {:host => host, :port => port}
  end

  opts.on("-w", "--war") do
    options[:war] = true
  end

  opts.on("-e EXAMPLE", "--example EXAMPLE") do |example_name|
    options[:example] = example_name
  end
end
option_parser.parse!

## DEBUG
#puts options.inspect

dir_or_file = ARGV.shift
if options[:example]
  dir_or_file = File.join(File.dirname(__FILE__), '../examples', options[:example], 'sample.rb')
end

raise "No application (or WAR) to start." if dir_or_file.nil?

if options[:war]
  options[:war] = dir_or_file
else
  options[:app_file] = dir_or_file
end

server = Kipatra::Server.new(options)
server.start
server.join

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kipatra-0.1.2 bin/kipatra