Sha256: 80e5e2046b338f5c92a5d0af2ef50fb7bf51e6d7909b09d88548a3eaa05afe53

Contents?: true

Size: 1.6 KB

Versions: 28

Compression:

Stored size: 1.6 KB

Contents

#!/usr/bin/env ruby

require 'rubygems'
require 'optparse'
require 'thin'

options = {
  :env => 'production'
}
optparse = OptionParser.new do |opts|

opts.banner = <<BANNER
Usage:
deltacloudd -i <driver> [options]

Options:
BANNER
  opts.on( '-i', '--driver DRIVER', 'Driver to use') do |driver|
    ENV["API_DRIVER"] = driver
  end
  opts.on( '-r', '--hostname HOSTNAME',
           'Bind to HOST address (default: localhost)') do |host|
    ENV["API_HOST"] = host
  end
  opts.on( '-p', '--port PORT', 'Use PORT (default: 3001)') do |port|
    ENV["API_PORT"] = port
  end
  opts.on( '-e', '--env ENV', 'Environment (default: "development")') { |env| options[:env] = env }
  opts.on( '-h', '--help', '') { options[:help] = true }
end

optparse.parse!

if options[:help]
 puts optparse
 exit(0)
end

unless ENV["API_DRIVER"]
  puts "You need to specify a driver to use (-i <driver>)"
  exit(1)
end

ENV["API_HOST"] = "localhost" unless ENV["API_HOST"]
ENV["API_PORT"] = "3001" unless ENV["API_PORT"]

dirname="#{File.dirname(__FILE__)}/.."

argv_opts = ARGV.clone
argv_opts << ['start'] unless Thin::Runner.commands.include?(options[0])
argv_opts << ['--address', ENV["API_HOST"] ]
argv_opts << ['--port', ENV["API_PORT"] ]
argv_opts << ['--rackup', 'config.ru' ]
argv_opts << ['--chdir', dirname ]
argv_opts << ['-e', options[:env] ]
argv_opts << ['--threaded', '-D', '--stats', '/stats']

argv_opts.flatten!

puts "Starting Deltacloud API :: #{ENV["API_DRIVER"]} :: http://#{ENV["API_HOST"]}:#{ENV["API_PORT"]}/api"
puts

thin = Thin::Runner.new(argv_opts)
begin
  thin.run!
rescue Exception => e
  puts "ERROR: #{e.message}"
end

Version data entries

28 entries across 28 versions & 3 rubygems

Version Path
steamcannon-deltacloud-core-0.1.2.1 support/fedora/deltacloudd
steamcannon-deltacloud-core-0.1.1.3 support/fedora/deltacloudd
deltacloud-core-0.1.2 support/fedora/deltacloudd
steamcannon-deltacloud-core-0.1.1.2 support/fedora/deltacloudd
steamcannon-deltacloud-core-0.1.1.1 support/fedora/deltacloudd
deltacloud-core-0.1.1 support/fedora/deltacloudd
deltacloud-core-0.1.0 support/fedora/deltacloudd
deltacloud-core-0.0.9 support/fedora/deltacloudd
steamcannon-deltacloud-core-0.0.8.1-java support/fedora/deltacloudd
steamcannon-deltacloud-core-0.0.8.1 support/fedora/deltacloudd
deltacloud-core-0.0.8 support/fedora/deltacloudd
steamcannon-deltacloud-core-0.0.7.2 support/fedora/deltacloudd
steamcannon-deltacloud-core-0.0.7.2-java support/fedora/deltacloudd
steamcannon-deltacloud-core-0.0.7.1 support/fedora/deltacloudd
steamcannon-deltacloud-core-0.0.7.1-java support/fedora/deltacloudd
deltacloud-core-0.0.7 support/fedora/deltacloudd
bbrowning-deltacloud-core-0.0.6.1-java support/fedora/deltacloudd
bbrowning-deltacloud-core-0.0.6-java support/fedora/deltacloudd
bbrowning-deltacloud-core-0.0.6 support/fedora/deltacloudd
deltacloud-core-0.0.6 support/fedora/deltacloudd