Skip to content

Commit

Permalink
server: add timeout for starting etcd
Browse files Browse the repository at this point in the history
  • Loading branch information
disksing committed Oct 11, 2018
1 parent 1c5f7d7 commit 2130d6c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (

const (
etcdTimeout = time.Second * 3
etcdStartTimeout = time.Minute * 5
serverMetricsInterval = time.Minute
// pdRootPath for all pd servers.
pdRootPath = "/pd"
Expand Down Expand Up @@ -134,6 +135,9 @@ func CreateServer(cfg *Config, apiRegister func(*Server) http.Handler) (*Server,

func (s *Server) startEtcd(ctx context.Context) error {
log.Info("start embed etcd")
ctx, cancel := context.WithTimeout(ctx, etcdStartTimeout)
defer cancel()

etcd, err := embed.StartEtcd(s.etcdCfg)
if err != nil {
return errors.WithStack(err)
Expand Down

0 comments on commit 2130d6c

Please sign in to comment.