Sha256: cceb2e4a47583dce30401c17a4e69d282c293e413cf3659811e757a4c2a39406

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

#!/usr/bin/env ruby

require 'rack'
require 'optparse'
require 'tamashii/manager/version'
require 'tamashii/manager/server'
require 'tamashii/manager'

options = {
  Port: ENV['PORT'] || 3000,
  Host: "0.0.0.0",
  AccessLog: []
}

OptionParser.new do |opts|
  opts.on("-v", "--version", "Display Tamashii::Manager version") {
    puts "Tamashii::Manager #{Tamashii::Manager::VERSION}"
    exit
  }

  opts.on("-h", "--help") {
    puts opts
    exit
  }

  opts.separator ""
  opts.on("-s", "--server SERVER", "Run Tamashii::Manager server") { |name| handlers.unshift(name.to_s) }
  opts.on("-o", "--host HOST", "The listen on HOST (default: 0.0.0.0)") { |host| options[:Host] = host.to_s; puts host }
  opts.on("-p", "--port PORT", "The listen on PORT (default: 3000)") { |port| options[:Port] = port.to_i }
  opts.on("-C", "--config FILE", "The external configuration file") { |config| require File.join(Dir.pwd, config) }

  opts.parse! ARGV
end

begin
  config = Tamashii::Manager::Config
  case config.auth_type
  when :token
    raise LoadError.new("Token authorization require to set token") if config.token.nil?
  end

  Rack::Handler.default.run Tamashii::Manager::Server, options
rescue LoadError => e
  # TODO: Improve error message
  STDERR.puts e
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tamashii-manager-0.1.4 exe/tamashii-manager