etcdserver/server.go
func (s *EtcdServer) Stop() {
	if err := s.TransferLeadership(); err != nil {
		if lg := s.getLogger(); lg != nil {
			lg.Warn("leadership transfer failed", zap.String("local-member-id", s.ID().String()), zap.Error(err))
		} else {
			plog.Warningf("%s failed to transfer leadership (%v)", s.ID(), err)
		}
	}
	s.HardStop()
}
func (s *EtcdServer) Stop() {
	if err := s.TransferLeadership(); err != nil {
		if lg := s.getLogger(); lg != nil {
			lg.Warn("leadership transfer failed", zap.String("local-member-id", s.ID().String()), zap.Error(err))
		} else {
			plog.Warningf("%s failed to transfer leadership (%v)", s.ID(), err)
		}
	}
	s.HardStop()
}
// Stop stops the server gracefully, and shuts down the running goroutine.
// Stop should be called after a Start(s), otherwise it will block forever.
// When stopping leader, Stop transfers its leadership to one of its peers
// before stopping the server.
// Stop terminates the Server and performs any necessary finalization.
// Do and Process cannot be called after Stop has been invoked.