Class: Wildnet::Server::Kernel

Inherits:
Object
  • Object
show all
Defined in:
lib/wildnet-server/kernel.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ Kernel

Returns a new instance of Kernel.



23
24
25
26
# File 'lib/wildnet-server/kernel.rb', line 23

def initialize app, options = {}
  @app     = app
  @options = options
end

Class Method Details

.run(app, options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/wildnet-server/kernel.rb', line 11

def self.run app, options = {}
  options[:Port] ||= 3000
  options[:Host] ||= "0.0.0.0"
  @@server       = self.new(app, options)
  @@server.start
  Thread.new do
    while true
      sleep 10
    end
  end.join
end

Instance Method Details

#startObject



28
29
30
31
32
# File 'lib/wildnet-server/kernel.rb', line 28

def start
  @bootstrap = ServerBootstrap.new(NioServerSocketChannelFactory.new(Executors.newCachedThreadPool, Executors.newCachedThreadPool))
  @bootstrap.setPipelineFactory(PipeLineFactory.new(@app))
  @bootstrap.bind(InetSocketAddress.new(@options[:Host], @options[:Port]))
end