Class: RubyWolf::Server

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rack_file, configs) ⇒ Server

Returns a new instance of Server.



5
6
7
8
9
# File 'lib/ruby_wolf/server.rb', line 5

def initialize(rack_file, configs)
  @rack_file = rack_file
  @configs = configs
  @workers = []
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



3
4
5
# File 'lib/ruby_wolf/server.rb', line 3

def app
  @app
end

#configsObject (readonly)

Returns the value of attribute configs.



3
4
5
# File 'lib/ruby_wolf/server.rb', line 3

def configs
  @configs
end

#socketObject (readonly)

Returns the value of attribute socket.



3
4
5
# File 'lib/ruby_wolf/server.rb', line 3

def socket
  @socket
end

#workersObject (readonly)

Returns the value of attribute workers.



3
4
5
# File 'lib/ruby_wolf/server.rb', line 3

def workers
  @workers
end

Instance Method Details

#startObject



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

def start
  trap_signal
  setup_rack
  setup_socket
  configs[:worker].times do
    workers << RubyWolf::Worker.new(self)
  end
  Process.detach if configs[:daemon]
  workers.each(&:start)
  handle_loop
end