Class: HttpKit::Server
- Inherits:
-
Object
- Object
- HttpKit::Server
- Defined in:
- lib/http_kit/server.rb
Class Method Summary collapse
Instance Method Summary collapse
- #run(app, options = {}) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object (also: #shutdown)
Class Method Details
.run(app, options = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/http_kit/server.rb', line 8 def Server.run(app, = {}) @lock.synchronize do return if @server @server = new @server.run(app, ) @server end end |
.stop ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/http_kit/server.rb', line 18 def Server.stop @lock.synchronize do return unless @server @server.stop @handler = nil end end |
Instance Method Details
#run(app, options = {}) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/http_kit/server.rb', line 27 def run(app, ={}) = { :host => "0.0.0.0", :port => 9292, :threads => 50, :queue => 1000, }.merge() @handler = HttpKit::RackHandler.new([:threads], app, "prefix-", [:queue]) @http_kit = Java::OrgHttpkitServer::HttpServer.new([:host], [:port], @handler, 80000, 4000) @http_kit.start $stdout.printf("HTTP Kit is listening on %s:%s\n", [:host], [:port]) trap("SIGINT") { @http_kit.stop exit } end |
#start ⇒ Object
48 49 50 |
# File 'lib/http_kit/server.rb', line 48 def start @http_kit.start end |
#stop ⇒ Object Also known as: shutdown
52 53 54 55 56 57 |
# File 'lib/http_kit/server.rb', line 52 def stop return unless @http_kit $stdout.print "Stopping Http kit..." unless @options[:quiet] @http_kit.stop $stdout.puts "done." unless @options[:quiet] end |