class Falcon::Service::Server

def initialize(...)

def initialize(...)
	super
	
	@bound_endpoint = nil
end

def preload!

Preload any resources specified by the environment.
def preload!
	root = @evaluator.root
	
	if scripts = @evaluator.preload
		scripts = Array(scripts)
		
		scripts.each do |path|
			Console.logger.info(self) {"Preloading #{path}..."}
			full_path = File.expand_path(path, root)
			load(full_path)
		end
	end
end

def setup(container)

@parameter container [Async::Container::Generic]
Setup the container with the application instance.
def setup(container)
	container_options = @evaluator.container_options
	
	container.run(name: self.name, **container_options) do |instance|
		evaluator = @environment.evaluator
		
		Async do |task|
			server = Falcon::Server.new(evaluator.middleware, @bound_endpoint, protocol: @endpoint.protocol, scheme: @endpoint.scheme)
			
			server.run
			
			instance.ready!
			
			task.children.each(&:wait)
		end
	end
end

def start

Prepare the bound endpoint for the server.
def start
	@endpoint = @evaluator.endpoint
	
	Sync do
		@bound_endpoint = @endpoint.bound
	end
	
	preload!
	
	Console.logger.info(self) {"Starting #{self.name} on #{@endpoint}"}
	
	super
end

def stop(...)

Close the bound endpoint.
def stop(...)
	if @bound_endpoint
		@bound_endpoint.close
		@bound_endpoint = nil
	end
	
	@endpoint = nil
	
	super
end