File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -161,7 +161,7 @@ func (u *Unit) RunContext(parentCtx context.Context) error {
161161 )
162162 logger := u .logger .Named ("unit" )
163163
164- ctx , cancel := context .WithCancelCause (parentCtx )
164+ runCtx , cancel := context .WithCancelCause (parentCtx )
165165 defer cancel (context .Canceled )
166166
167167 wg := sync.WaitGroup {}
@@ -199,35 +199,39 @@ func (u *Unit) RunContext(parentCtx context.Context) error {
199199
200200 select {
201201 case registry = <- metricsInitialized :
202- case <- ctx .Done ():
203- return context .Cause (ctx )
202+ case <- runCtx .Done ():
203+ return context .Cause (runCtx )
204204 }
205205
206206 select {
207207 case traceProvider = <- tracingInitialized :
208- case <- ctx .Done ():
209- return context .Cause (ctx )
208+ case <- runCtx .Done ():
209+ return context .Cause (runCtx )
210210 }
211211
212212 wg .Go (
213213 func () {
214214
215- if err := u .main .Run (ctx , u .logger , registry , traceProvider ); err != nil {
215+ if err := u .main .Run (runCtx , u .logger , registry , traceProvider ); err != nil {
216216 cancel (err )
217217 }
218218 },
219219 )
220220
221- ctx , stop := signal .NotifyContext (ctx , os .Interrupt , syscall .SIGTERM )
221+ signalCtx , stop := signal .NotifyContext (runCtx , os .Interrupt , syscall .SIGTERM )
222222 defer stop ()
223223
224- <- ctx .Done ()
224+ <- signalCtx .Done ()
225225
226226 stopMetricsServer ()
227227 stopTracingExporter ()
228228
229229 wg .Wait ()
230230
231+ if cause := context .Cause (runCtx ); cause != nil {
232+ return cause
233+ }
234+
231235 return context .Canceled
232236}
233237
You can’t perform that action at this time.
0 commit comments