class Async::Container::Supervisor::Service

def endpoint

Typically a unix pipe in the same directory as the host.
The endpoint which the supervisor will bind to.
def endpoint
	@evaluator.endpoint
end

def initialize(...)

@parameter environment [Build::Environment]
Initialize the supervisor using the given environment.
def initialize(...)
	super
	
	@bound_endpoint = nil
end

def name

def name
	@evaluator.name
end

def setup(container)

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 start

Bind the supervisor to the specified endpoint.
def start
	@bound_endpoint = self.endpoint.bound
	
	super
end

def stop

Release the bound endpoint.
def stop
	@bound_endpoint&.close
	@bound_endpoint = nil
	
	super
end