class Service
The supervisor service implementation.
Manages the lifecycle of the supervisor server and its monitors.
Definitions
def initialize(...)
Initialize the supervisor using the given environment.
Signature
-
parameter
environmentBuild::Environment
Implementation
def initialize(...)
super
@bound_endpoint = nil
end
def endpoint
The endpoint which the supervisor will bind to. Typically a unix pipe in the same directory as the host.
Implementation
def endpoint
@evaluator.endpoint
end
def start
Bind the supervisor to the specified endpoint.
Implementation
def start
@bound_endpoint = self.endpoint.bound
super
end
def name
Get the name of the supervisor service.
Signature
-
returns
String The service name.
Implementation
def name
@evaluator.name
end
def setup(container)
Set up the supervisor service in the container.
Creates and runs the supervisor server with configured monitors.
Signature
-
parameter
containerAsync::Container::Generic The container to set up in.
Implementation
def setup(container)
container_options = @evaluator.container_options
health_check_timeout = container_options[:health_check_timeout]
container.run(name: self.name, **container_options) do |instance|
evaluator = @environment.evaluator
Async do
server = evaluator.make_server(@bound_endpoint)
server.run
instance.ready!
if health_check_timeout
Async(transient: true) do
while true
sleep(health_check_timeout / 2)
instance.ready!
end
end
end
end
end
super
end
def stop
Release the bound endpoint.
Implementation
def stop
@bound_endpoint&.close
@bound_endpoint = nil
super
end