File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
extension/healthcheckv2extension/internal/http Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change 9
9
"errors"
10
10
"fmt"
11
11
"net/http"
12
+ "sync"
12
13
"sync/atomic"
13
14
"time"
14
15
@@ -32,7 +33,7 @@ type Server struct {
32
33
colconf atomic.Value
33
34
aggregator * status.Aggregator
34
35
startTimestamp time.Time
35
- doneCh chan struct {}
36
+ doneWg sync. WaitGroup
36
37
}
37
38
38
39
var (
@@ -52,7 +53,6 @@ func NewServer(
52
53
telemetry : telemetry ,
53
54
mux : http .NewServeMux (),
54
55
aggregator : aggregator ,
55
- doneCh : make (chan struct {}),
56
56
}
57
57
58
58
if legacyConfig .UseV2 {
@@ -96,8 +96,10 @@ func (s *Server) Start(ctx context.Context, host component.Host) error {
96
96
return fmt .Errorf ("failed to bind to address %s: %w" , s .httpConfig .Endpoint , err )
97
97
}
98
98
99
+ s .doneWg .Add (1 )
99
100
go func () {
100
- defer close (s .doneCh )
101
+ defer s .doneWg .Done ()
102
+
101
103
if err = s .httpServer .Serve (ln ); ! errors .Is (err , http .ErrServerClosed ) && err != nil {
102
104
componentstatus .ReportStatus (host , componentstatus .NewPermanentErrorEvent (err ))
103
105
}
@@ -112,7 +114,7 @@ func (s *Server) Shutdown(context.Context) error {
112
114
return nil
113
115
}
114
116
s .httpServer .Close ()
115
- <- s . doneCh
117
+ s . doneWg . Wait ()
116
118
return nil
117
119
}
118
120
You can’t perform that action at this time.
0 commit comments