Module: SimpleAcp::Server::FalconRunner
- Defined in:
- lib/simple_acp/server/falcon_runner.rb
Overview
Falcon-based server runner using fiber concurrency.
Provides efficient handling of SSE streams and long-lived connections through Async's fiber scheduler.
Class Method Summary collapse
-
.run(app, port: 8000, host: "0.0.0.0", **options) ⇒ void
Start the server using Falcon.
Class Method Details
.run(app, port: 8000, host: "0.0.0.0", **options) ⇒ void
This method returns an undefined value.
Start the server using Falcon.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/simple_acp/server/falcon_runner.rb', line 29 def self.run(app, port: 8000, host: "0.0.0.0", **) endpoint = IO::Endpoint::AddressEndpoint.new(Addrinfo.tcp(host, port)) puts "ACP Server (Falcon) running on http://#{host}:#{port}" server_task = nil # Handle interrupt for graceful shutdown trap("INT") do puts "\nShutting down..." Thread.main.raise(Interrupt) end trap("TERM") do puts "\nShutting down..." Thread.main.raise(Interrupt) end begin Sync do |task| rack_app = Protocol::Rack::Adapter.new(app) server = Falcon::Server.new(rack_app, endpoint, protocol: Async::HTTP::Protocol::HTTP1, scheme: "http") server_task = server.run server_task.wait end rescue Interrupt # Graceful shutdown end end |