Sha256: a9cadd392e43bc6f4ea2dede58fdb0dbce5ef79293747e130e57c64df87d5769

Contents?: true

Size: 1.54 KB

Versions: 1

Compression:

Stored size: 1.54 KB

Contents

#!/usr/bin/env ruby

require 'colorize'
require 'optparse'

require 'nephos-server/version'
require 'nephos-server/bin-helpers'

class RoutingError < StandardError; end

begin
  opts = OptionParser.new do |opts|
    opts.banner = "Usage<#{Nephos::VERSION}>: nephos-server <options>"

    $server_port = ENV["SERVER_PORT"] || 8080
    opts.on("-p=nb", "--port=nb", "Port to listen") 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", "Enable debugging mode") do
      $debug = true
    end

    opts.on("--test", "Enable testing mode (for nephos developpers)") do
      $test = true
    end

  end.parse!

  Dir.chdir(opts[0]) if not opts.empty?

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

  if not $test 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

1 entries across 1 versions & 1 rubygems

Version Path
nephos-server-0.5.2 bin/nephos-server