Class: Funnel::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/funnel/server.rb

Class Method Summary collapse

Class Method Details

.start(host, port) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/funnel/server.rb', line 4

def self.start host, port

  raise "Reactor already running" if EM.reactor_running?

  EM.epoll  if EM.epoll?
  EM.kqueue if EM.kqueue?

  Log.info "Starting Funnel Server..."

  EM.run do

    trap("TERM") { stop }
    trap("INT")  { stop }

    EM.start_server(host, port, Routing::Router)

    Log.info "Server Listening on #{host}:#{port}"
  end
end

.stopObject



24
25
26
27
# File 'lib/funnel/server.rb', line 24

def self.stop
  Log.info "Funnel Server Shutting Down"
  EM.stop
end