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:
Benjamin Wang
2024-12-12 21:45:28 +00:00
parent 2cf717251e
commit 93b01af668

View File

@ -16,6 +16,7 @@ package embed
import (
"context"
"errors"
"fmt"
"io"
defaultLog "log"
@ -102,6 +103,12 @@ func (sctx *serveCtx) serve(
logger := defaultLog.New(io.Discard, "etcdhttp", 0)
<-s.ReadyNotify()
select {
case <-s.StoppingNotify():
return errors.New("server is stopping")
case <-s.ReadyNotify():
}
sctx.lg.Info("ready to serve client requests")
m := cmux.New(sctx.l)