Sha256: 4df47e61598e67cb12913c7ebb35d6a584ad9a28e9a30b534bfa1bc31cfafa41

Contents?: true

Size: 893 Bytes

Versions: 1

Compression:

Stored size: 893 Bytes

Contents

require 'rack/server'
require 'rack/builder'

module NetworkExecutive

  class Server < Rack::Server

    def initialize(*)
      super

      yield self if block_given?
    end

    def start
      puts "http://#{options[:Host]}:#{options[:Port]}"
      puts "=> Booting Network Executive v#{NetworkExecutive::VERSION}"
      trap(:INT) { exit }
      puts '=> Ctrl-C to shutdown server'

      super
    ensure
      puts 'Exiting'
    end

    def app
      @app ||= super.respond_to?(:to_app) ? super.to_app : super
    end

    def default_options
      rackup_file = Dir['*.ru'].first

      super.merge({
        Port:        3000,
        environment: (ENV['RACK_ENV'] || 'development').dup,
        config:      File.expand_path( rackup_file )
      })
    end

    class << self
      def start!
        new do |server|
          server.start
        end
      end
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
network_executive-0.0.1.alpha.1 lib/network_executive/commands/server.rb