Sha256: 8b31eef0caca90ba920820d25c77bb0337a864f7619add19b98416d628d045c3

Contents?: true

Size: 1.29 KB

Versions: 2

Compression:

Stored size: 1.29 KB

Contents

#!/usr/bin/env ruby

require 'colorize'
require 'optparse'

class RoutingError < StandardError; end

begin
  OptionParser.new do |opts|
    opts.banner = "Usage: nephos-server [-p=port] [-h=listen] [--debug]"

    $server_port = ENV["SERVER_PORT"] || 8080
    opts.on("-p=nb", "--port=nb", "Port") do |port|
      $server_port = Integer(port)
    end

    $server_host = ENV["SERVER_HOST"] || "0.0.0.0"
    opts.on("-h=listen", "--host=listen", "Listen on the network") do |host|
      $server_host = host
    end

    $server_env = ENV["ENVIRONMENT"] || "development"
    opts.on("-e=env", "--env=env", "Environment") do |env|
      $server_env = env
    end

    opts.on("--debug") do
      $debug = true
    end
  end.parse!

  if $debug
    require_relative "../lib/nephos-server"
  else
    require 'nephos-server'
  end

  if not $debug and
    (not File.exists? "Gemfile.lock" or
     not File.read("Gemfile.lock").split.index("nephos-server"))
    raise InvalidApplication
  end

  puts "Running Nephos::Server version #{Nephos::VERSION} (#{Nephos.env})"
  Nephos::Server.start($server_port, $server_host)

rescue RoutingError => err
  puts "Routing Error: Check out the documentation and `routes.rb` file.".yellow
  puts "#{err.class}: #{err.message}".red

rescue => err
  puts "#{err.class}: #{err.message}".red
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nephos-server-0.4.8 bin/nephos-server
nephos-server-0.4.7 bin/nephos-server