Sha256: 2b37142feaf5d90fb7268572232129eb35de7ca8c58d3fd02a5fca31a17ebafc

Contents?: true

Size: 1.6 KB

Versions: 4

Compression:

Stored size: 1.6 KB

Contents

#!/usr/bin/env ruby

require File.expand_path(File.join(File.dirname(__FILE__), '..', 'castronaut'))
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../vendor/sinatra/lib')
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../vendor/rack/lib')

require 'rack'
require 'sinatra'
require 'optparse'

OptionParser.new do |opts|
  opts.banner = "Usage: castronaut -C /path/to/config/file"

  opts.on("-h", "--help") do
    puts opts.banner
    exit(1)
  end

  opts.on("-C", "--config FILE", "Config File") do |c|
    Castronaut.config = Castronaut::Configuration.load c
  end
end.parse!

unless Castronaut.config
  $stderr.puts "No configuration file specified.  Defaulting to ./config/castronaut.yml"
  default_config = File.expand_path("./config/castronaut.yml")

  if File.exist?(default_config)
    Castronaut.config = Castronaut::Configuration.load(default_config)
  else
    puts "Unable to locate configuration.  Currently looking at #{default_config}.  You can pass a custom configuration path by using the -C flag."
    exit(0)
  end
end

Sinatra::Application.default_options.merge!(
  :env => Castronaut.config.environment.to_sym,
  :run => true,
  :raise_errors => true,
  :logging => true,
  :port => Castronaut.config.respond_to?(:server_port) ? Castronaut.config.server_port : Sinatra::Application.default_options[:port]
)

Castronaut.logger.info("Sinatra - Loading app/config.rb")
load File.expand_path(File.join(File.dirname(__FILE__), '..', 'app', 'config.rb'))

Castronaut.logger.info("Sinatra - Loading app/application.rb")
load File.expand_path(File.join(File.dirname(__FILE__), '..', 'app', 'controllers', 'application.rb'))

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
3mix-castronaut-0.5.0.2 bin/castronaut
masover-castronaut-0.4.4.4 bin/castronaut
masover-castronaut-0.4.4.5 bin/castronaut
masover-castronaut-0.5.0.1 bin/castronaut