Skip to content

Commit

Permalink
Move listen calls to the main goroutine
Browse files Browse the repository at this point in the history
  • Loading branch information
vflaux committed Jan 22, 2025
1 parent 3ed7719 commit 1d034b4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,12 @@ func registryCommand(ctx context.Context, args *RegistryCmd) (err error) {
Addr: args.MetricsAddr,
Handler: mux,
}
metricsLn, err := net.Listen("tcp", metricsSrv.Addr)
if err != nil {
return err
}
g.Go(func() error {
if err := metricsSrv.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
if err := metricsSrv.Serve(metricsLn); err != nil && !errors.Is(err, http.ErrServerClosed) {
return err
}
return nil
Expand Down Expand Up @@ -212,8 +216,12 @@ func registryCommand(ctx context.Context, args *RegistryCmd) (err error) {
if err != nil {
return err
}
regLn, err := net.Listen("tcp", regSrv.Addr)
if err != nil {
return err
}
g.Go(func() error {
if err := regSrv.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
if err := regSrv.Serve(regLn); err != nil && !errors.Is(err, http.ErrServerClosed) {
return err
}
return nil
Expand Down

0 comments on commit 1d034b4

Please sign in to comment.