Skip to content

Commit 724d53d

Browse files
authored
Fix shutdown when proxy is killed by a signal (#83)
* Fix shutdown when proxy is killed by a signal * Ignore http server closed error
1 parent 7d5dd17 commit 724d53d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

proxy/run.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,11 @@ func listenAndServe(p *Proxy, ctx context.Context, logger *zap.Logger) (err erro
264264

265265
wg.Add(numServers)
266266

267+
go func() {
268+
wg.Wait()
269+
close(ch)
270+
}()
271+
267272
go func() {
268273
select {
269274
case <-ctx.Done():
@@ -275,7 +280,7 @@ func listenAndServe(p *Proxy, ctx context.Context, logger *zap.Logger) (err erro
275280

276281
go func() {
277282
defer wg.Done()
278-
err = p.Serve()
283+
err := p.Serve()
279284
if err != nil && err != ErrProxyClosed {
280285
ch <- err
281286
}
@@ -284,8 +289,8 @@ func listenAndServe(p *Proxy, ctx context.Context, logger *zap.Logger) (err erro
284289
if cli.HealthCheck {
285290
go func() {
286291
defer wg.Done()
287-
err = server.Serve(listener)
288-
if err != nil {
292+
err := server.Serve(listener)
293+
if err != nil && err != http.ErrServerClosed {
289294
ch <- err
290295
}
291296
}()

0 commit comments

Comments
 (0)