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.



7
8
9
10
11
# File 'lib/ruby_wolf/server.rb', line 7

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

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



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

def app
  @app
end

#configsObject (readonly)

Returns the value of attribute configs.



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

def configs
  @configs
end

#socketObject (readonly)

Returns the value of attribute socket.



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

def socket
  @socket
end

#workersObject (readonly)

Returns the value of attribute workers.



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

def workers
  @workers
end

Instance Method Details

#startObject



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

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