Class: Insika::DSL::ServerBoot
- Inherits:
-
Object
- Object
- Insika::DSL::ServerBoot
- Defined in:
- lib/insika/dsl/server_boot.rb
Instance Method Summary collapse
-
#initialize(runtime, port:, host:, token:) ⇒ ServerBoot
constructor
A new instance of ServerBoot.
- #run ⇒ Object
Constructor Details
#initialize(runtime, port:, host:, token:) ⇒ ServerBoot
Returns a new instance of ServerBoot.
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/insika/dsl/server_boot.rb', line 20 def initialize(runtime, port:, host:, token:) @rt = runtime @graph = runtime.graph @port = port @host = host # Fixed local token: logs into the Studio (cookie) and gates /v1 (Bearer). # Never a real secret — override with `token:` or ADMIN_TOKEN. @token = token || ENV.fetch("ADMIN_TOKEN", "local-demo") # RFC-0017 A3: the /v1 app is a value now — the same one a host mounts. # This boot adds the Studio and a reactor around it, nothing else. @builder = Insika::Server::AppBuilder.new(runtime, token: @token) end |
Instance Method Details
#run ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/insika/dsl/server_boot.rb', line 33 def run configure_studio dispatch = Rack::URLMap.new("/studio" => Studio::App, "/" => @builder.app) endpoint = Async::HTTP::Endpoint.parse("http://#{@host}:#{@port}") middleware = Protocol::Rack::Adapter.new(dispatch) # Item 16 / P4: the OTEL bridge is opt-in but must be reachable from the DSL # front door too — the convention is worthless if only config.ru can export. # nil (the default) -> attach is a no-op and no gem is loaded. telemetry = Insika::Telemetry.setup(service_name: ENV.fetch("OTEL_SERVICE_NAME", "insika")) (telemetry) # RFC-0016 A3: first Ctrl-C/SIGTERM closes the intake and drains in-flight # turns (INSIKA_DRAIN_TIMEOUT, default 20s); a second signal skips the wait. Insika::Shutdown.install(executor: @graph.executor) Async do @graph.executor.supervised = true # serving mode: turns survive disconnects Insika::Telemetry.attach(event_stream: @graph.event_stream, recorder: telemetry) Async::HTTP::Server.new(middleware, endpoint).run end end |