FalconSourceFalconServiceServer

class Server

Definitions

def start

Prepare the bound endpoint for the server.

Implementation

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

def run(instance, evaluator)

Run the service logic.

Signature

parameter instance Object

The container instance.

parameter evaluator Environment::Evaluator

The environment evaluator.

returns Falcon::Server

The server instance.

Implementation

def run(instance, evaluator)
	if evaluator.key?(:make_supervised_worker)
		Console.warn(self, "Async::Container::Supervisor is replaced by Async::Services::Supervisor, please update your service definition.")
		
		evaluator.make_supervised_worker(instance).run
	end
	
	server = evaluator.make_server(@bound_endpoint)
	
	Async do |task|
		server.run
		
		task.children.each(&:wait)
	end
	
	server
end

def stop(...)

Close the bound endpoint.

Implementation

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