Sha256: aeeb2bbca959e84892b7a718cfc2f435dcab1a2bcb381c8172ef27ed35925aca

Contents?: true

Size: 925 Bytes

Versions: 2

Compression:

Stored size: 925 Bytes

Contents

require 'rack/handler'
require 'jubilee'
require 'java'

module Rack
  module Handler
    module Jubilee
      DEFAULT_OPTIONS = {
        :host => '0.0.0.0',
        :port => 3000,
        :verbose => false
      }
      def self.run(app, options = {})
        options = DEFAULT_OPTIONS.merge(options)

        if options[:verbose]
          app = Rack::CommonLogger.new(app, STDOUT)
        end

        if options[:environment]
          ENV["RACK_ENV"] = options[:environment].to_s
        end

        @server = ::Jubilee::Server.new(app, options)

        puts "Jubilee starting..."
        puts "Environment: #{ENV['RACK_ENV']}"

        yield @server if block_given?

        @server.start
        @starter = org.jruby.jubilee.deploy.Starter.new
        @starter.block
      end

      def self.shutdown
        @server.stop{ @starter.unblock }
        exit
      end
    end
    register :jubilee, Jubilee
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jubilee-0.2.0 lib/rack/handler/jubilee.rb
jubilee-0.1.2 lib/rack/handler/jubilee.rb