Module: Ratalada::Server

Defined in:
lib/ratalada.rb

Class Method Summary collapse

Class Method Details

.run(host: DEFAULT_HOST, port: DEFAULT_PORT, count: DEFAULT_COUNT, &block) ⇒ Object

count runs that many worker processes accepting from a shared socket, like node's cluster module. Each worker has its own state — anything shared (sessions, caches) needs an external store or count: 1.

Raises:

  • (ArgumentError)


110
111
112
113
114
115
116
# File 'lib/ratalada.rb', line 110

def run(host: DEFAULT_HOST, port: DEFAULT_PORT, count: DEFAULT_COUNT, &block)
  raise ArgumentError, "Server.run requires a block" unless block
  raise ArgumentError, "count must be a positive Integer" unless count.is_a?(Integer) && count.positive?

  app = Ratalada.frontend.build(block)
  Ratalada.backend.run(app, host: host, port: port, count: count)
end