Module: Ratalada::Backends::Falcon
- Defined in:
- lib/ratalada/falcon.rb
Class Method Summary collapse
-
.run(app, host:, port:, count: 1) ⇒ Object
Runs the app the way
falcon hostdoes: declare a server environment, hand it to Async::Service::Controller.
Class Method Details
.run(app, host:, port:, count: 1) ⇒ Object
Runs the app the way falcon host does: declare a server environment,
hand it to Async::Service::Controller. The controller binds the socket
once in the parent, runs count supervised workers accepting from it
(restarts, health checks, INT/TERM/HUP handling all come with it).
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ratalada/falcon.rb', line 19 def run(app, host:, port:, count: 1) middleware = ::Falcon::Server.middleware(app) environment = Async::Service::Environment.new(::Falcon::Environment::Server).with( name: "ratalada", url: "http://#{host}:#{port}", middleware: -> { middleware }, container_options: { count: count, restart: true }, ) configuration = Async::Service::Configuration.new configuration.add(environment) warn "ratalada: falcon listening on http://#{host}:#{port}#{" (#{count} workers)" if count > 1}" Async::Service::Controller.run(configuration, container_class: Async::Container.best_container_class) rescue Interrupt # clean shutdown end |