@@ -59,19 +59,21 @@ def start
5959 # Override this method to emit metrics, logs, or perform other actions when the service preparation is complete.
6060 #
6161 # @parameter instance [Async::Container::Instance] The container instance.
62- # @parameter start_time [Async::Clock] The monotonic start time from {Async::Clock.start}.
63- def emit_prepared ( instance , start_time )
62+ # @parameter clock [Async::Clock] The monotonic start time from {Async::Clock.start}.
63+ def emit_prepared ( instance , clock )
6464 # Override in subclasses as needed.
65+ Console . info ( self , "Prepared..." , duration : clock . total )
6566 end
6667
6768 # Called after the service has started running.
6869 #
6970 # Override this method to emit metrics, logs, or perform other actions when the service begins running.
7071 #
7172 # @parameter instance [Async::Container::Instance] The container instance.
72- # @parameter start_time [Async::Clock] The monotonic start time from {Async::Clock.start}.
73- def emit_running ( instance , start_time )
73+ # @parameter clock [Async::Clock] The monotonic start time from {Async::Clock.start}.
74+ def emit_running ( instance , clock )
7475 # Override in subclasses as needed.
76+ Console . info ( self , "Running..." , duration : clock . total )
7577 end
7678
7779 # Set up the container with health checking and process title formatting.
@@ -83,22 +85,27 @@ def setup(container)
8385 health_check_timeout = container_options [ :health_check_timeout ]
8486
8587 container . run ( **container_options ) do |instance |
86- start_time = Async ::Clock . start
88+ clock = Async ::Clock . start
8789
8890 Async do
8991 evaluator = self . environment . evaluator
92+ server = nil
93+
94+ health_checker ( instance , health_check_timeout ) do
95+ if server
96+ instance . name = format_title ( evaluator , server )
97+ end
98+ end
9099
91100 instance . status! ( "Preparing..." )
92101 evaluator . prepare! ( instance )
93- emit_prepared ( instance , start_time )
102+ emit_prepared ( instance , clock )
94103
95104 instance . status! ( "Running..." )
96105 server = run ( instance , evaluator )
97- emit_running ( instance , start_time )
106+ emit_running ( instance , clock )
98107
99- health_checker ( instance ) do
100- instance . name = format_title ( evaluator , server )
101- end
108+ instance . ready!
102109 end
103110 end
104111 end
0 commit comments