mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-03 02:42:19 +08:00
fix: fix the netDone
This commit is contained in:
parent
38d3064399
commit
c1a1e759c1
@ -108,7 +108,7 @@ func Start(
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
netDone = make(chan struct{}, 1)
|
netDone = make(chan struct{}, 2)
|
||||||
netErr error
|
netErr error
|
||||||
httpServer *http.Server
|
httpServer *http.Server
|
||||||
)
|
)
|
||||||
@ -119,7 +119,7 @@ func Start(
|
|||||||
httpServer = &http.Server{Handler: promhttp.HandlerFor(reg, promhttp.HandlerOpts{}), Addr: fmt.Sprintf("0.0.0.0:%d", prometheusPort)}
|
httpServer = &http.Server{Handler: promhttp.HandlerFor(reg, promhttp.HandlerOpts{}), Addr: fmt.Sprintf("0.0.0.0:%d", prometheusPort)}
|
||||||
if err := httpServer.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
if err := httpServer.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
||||||
netErr = errs.Wrap(err, "prometheus start err", httpServer.Addr)
|
netErr = errs.Wrap(err, "prometheus start err", httpServer.Addr)
|
||||||
close(netDone)
|
netDone <- struct{}{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
@ -128,7 +128,7 @@ func Start(
|
|||||||
err := srv.Serve(listener)
|
err := srv.Serve(listener)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
netErr = errs.Wrap(err, "rpc start err: ", rpcTcpAddr)
|
netErr = errs.Wrap(err, "rpc start err: ", rpcTcpAddr)
|
||||||
close(netDone)
|
netDone <- struct{}{}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ func Start(
|
|||||||
|
|
||||||
select {
|
select {
|
||||||
case <-sigs:
|
case <-sigs:
|
||||||
print("receive process terminal SIGUSR1 exit")
|
print("receive process terminal SIGUSR1 exit\n")
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
if err := gracefulStopWithCtx(ctx, srv.GracefulStop); err != nil {
|
if err := gracefulStopWithCtx(ctx, srv.GracefulStop); err != nil {
|
||||||
@ -150,6 +150,7 @@ func Start(
|
|||||||
return errs.Wrap(err, "shutdown err")
|
return errs.Wrap(err, "shutdown err")
|
||||||
}
|
}
|
||||||
case <-netDone:
|
case <-netDone:
|
||||||
|
close(netDone)
|
||||||
return netErr
|
return netErr
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user