mirror of
https://github.com/actions/actions-runner-controller.git
synced 2025-12-20 06:56:51 +00:00
Shutdown metrics server when listener exits (#3445)
This commit is contained in:
@@ -117,15 +117,19 @@ func (app *App) Run(ctx context.Context) error {
|
||||
}
|
||||
|
||||
g, ctx := errgroup.WithContext(ctx)
|
||||
metricsCtx, cancelMetrics := context.WithCancelCause(ctx)
|
||||
|
||||
g.Go(func() error {
|
||||
app.logger.Info("Starting listener")
|
||||
return app.listener.Listen(ctx, app.worker)
|
||||
listnerErr := app.listener.Listen(ctx, app.worker)
|
||||
cancelMetrics(fmt.Errorf("Listener exited: %w", listnerErr))
|
||||
return listnerErr
|
||||
})
|
||||
|
||||
if app.metrics != nil {
|
||||
g.Go(func() error {
|
||||
app.logger.Info("Starting metrics server")
|
||||
return app.metrics.ListenAndServe(ctx)
|
||||
return app.metrics.ListenAndServe(metricsCtx)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user