File tree Expand file tree Collapse file tree 2 files changed +22
-5
lines changed
Expand file tree Collapse file tree 2 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,12 @@ module Falcon
1212 module Environment
1313 # Provides an environment for hosting a supervisor which can monitor multiple applications.
1414 module Supervisor
15+ # The service class to use for the supervisor.
16+ # @returns [Class]
17+ def service_class
18+ ::Falcon ::Service ::Supervisor
19+ end
20+
1521 # The name of the supervisor
1622 # @returns [String]
1723 def name
@@ -30,10 +36,9 @@ def endpoint
3036 ::IO ::Endpoint . unix ( ipc_path )
3137 end
3238
33- # The service class to use for the supervisor.
34- # @returns [Class]
35- def service_class
36- ::Falcon ::Service ::Supervisor
39+ # Options to use when creating the container.
40+ def container_options
41+ { restart : true , count : 1 , health_check_timeout : 30 }
3742 end
3843 end
3944
Original file line number Diff line number Diff line change @@ -69,7 +69,10 @@ def start
6969 # Start the supervisor process which accepts connections from the bound endpoint and processes JSON formatted messages.
7070 # @parameter container [Async::Container::Generic]
7171 def setup ( container )
72- container . run ( name : self . name , restart : true , count : 1 ) do |instance |
72+ container_options = @evaluator . container_options
73+ health_check_timeout = container_options [ :health_check_timeout ]
74+
75+ container . run ( name : self . name , **container_options ) do |instance |
7376 Async do
7477 @bound_endpoint . accept do |peer |
7578 stream = ::IO ::Stream ( peer )
@@ -81,6 +84,15 @@ def setup(container)
8184 end
8285
8386 instance . ready!
87+
88+ if health_check_timeout
89+ Async ( transient : true ) do
90+ while true
91+ sleep ( health_check_timeout / 2 )
92+ instance . ready!
93+ end
94+ end
95+ end
8496 end
8597 end
8698
You can’t perform that action at this time.
0 commit comments