mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-30 00:09:07 +01:00
Pass the ctx to the close function
This commit is contained in:
@@ -3,7 +3,6 @@ package server
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"time"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
@@ -61,15 +60,12 @@ func (r *Server) Listen(cfg ListenerConfig) error {
|
||||
|
||||
// Close stops the relay server. If there are active connections, they will be closed gracefully. In case of a timeout,
|
||||
// the connections will be forcefully closed.
|
||||
func (r *Server) Close() (err error) {
|
||||
func (r *Server) Close(ctx context.Context) (err error) {
|
||||
// stop service new connections
|
||||
if r.wSListener != nil {
|
||||
err = r.wSListener.Close()
|
||||
err = r.wSListener.Close(ctx)
|
||||
}
|
||||
|
||||
// close accepted connections gracefully
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer cancel()
|
||||
r.relay.Close(ctx)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user