Do not wait for ready notify if the server is stopping
Signed-off-by: Benjamin Wang <benjamin.ahrtr@gmail.com>
This commit is contained in:
@ -16,6 +16,7 @@ package embed
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
defaultLog "log"
|
defaultLog "log"
|
||||||
@ -102,6 +103,12 @@ func (sctx *serveCtx) serve(
|
|||||||
logger := defaultLog.New(io.Discard, "etcdhttp", 0)
|
logger := defaultLog.New(io.Discard, "etcdhttp", 0)
|
||||||
<-s.ReadyNotify()
|
<-s.ReadyNotify()
|
||||||
|
|
||||||
|
select {
|
||||||
|
case <-s.StoppingNotify():
|
||||||
|
return errors.New("server is stopping")
|
||||||
|
case <-s.ReadyNotify():
|
||||||
|
}
|
||||||
|
|
||||||
sctx.lg.Info("ready to serve client requests")
|
sctx.lg.Info("ready to serve client requests")
|
||||||
|
|
||||||
m := cmux.New(sctx.l)
|
m := cmux.New(sctx.l)
|
||||||
|
Reference in New Issue
Block a user