Class: Async::Service::Supervisor::Service

Inherits:
Managed::Service
  • Object
show all
Defined in:
lib/async/service/supervisor/service.rb

Overview

The supervisor service implementation.

Manages the lifecycle of the supervisor server and its monitors.

Instance Method Summary collapse

Constructor Details

#initializeService

Initialize the supervisor using the given environment.



19
20
21
22
23
# File 'lib/async/service/supervisor/service.rb', line 19

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

Instance Method Details

#endpointObject

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



27
28
29
# File 'lib/async/service/supervisor/service.rb', line 27

def endpoint
	@evaluator.endpoint
end

#run(instance, evaluator) ⇒ Object

Run the supervisor server.



52
53
54
55
56
57
58
59
60
61
# File 'lib/async/service/supervisor/service.rb', line 52

def run(instance, evaluator)
	server = evaluator.make_server(@bound_endpoint)
	
	Async do |task|
		server.run
	end
	
	# Return the server for health checking and process title formatting
	server
end

#startObject

Bind the supervisor to the specified endpoint.



32
33
34
35
36
# File 'lib/async/service/supervisor/service.rb', line 32

def start
	@bound_endpoint = self.endpoint.bound
	
	super
end

#stopObject

Release the bound endpoint.



64
65
66
67
68
69
# File 'lib/async/service/supervisor/service.rb', line 64

def stop
	@bound_endpoint&.close
	@bound_endpoint = nil
	
	super
end