lxd/cluster/raft.go
func (i *raftInstance) Shutdown() error {
	logger.Debug("Stop raft instance")

	// Invoke raft APIs asynchronously to allow for a timeout.
	timeout := 10 * time.Second

	errCh := make(chan error)
	timer := time.After(timeout)
	go func() {
		errCh <- i.raft.Shutdown().Error()
	}()
	select {
	case err := <-errCh:
		if err != nil {
			return errors.Wrap(err, "failed to shutdown raft")
		}
	case <-timer:
		logger.Debug("Timeout waiting for raft to shutdown")
		return fmt.Errorf("raft did not shutdown within %s", timeout)

	}
	err := i.logs.Close()
	if err != nil {
		return errors.Wrap(err, "failed to close boltdb logs store")
	}
	return nil
}
func (i *raftInstance) Shutdown() error {
	logger.Debug("Stop raft instance")

	// Invoke raft APIs asynchronously to allow for a timeout.
	timeout := 10 * time.Second

	errCh := make(chan error)
	timer := time.After(timeout)
	go func() {
		errCh <- i.raft.Shutdown().Error()
	}()
	select {
	case err := <-errCh:
		if err != nil {
			return errors.Wrap(err, "failed to shutdown raft")
		}
	case <-timer:
		logger.Debug("Timeout waiting for raft to shutdown")
		return fmt.Errorf("raft did not shutdown within %s", timeout)

	}
	err := i.logs.Close()
	if err != nil {
		return errors.Wrap(err, "failed to close boltdb logs store")
	}
	return nil
}
func ( i * raftInstance ) Shutdown ( ) error { logger . Debug ( " " ) // Invoke raft APIs asynchronously to allow for a timeout. timeout := 10 * time . Second errCh := make ( chan error ) timer := time . After ( timeout ) go func ( ) { errCh <- i . raft . Shutdown ( ) . Error ( ) } ( ) select { case err := <- errCh : if err != nil { return errors . Wrap ( err , " " ) } case <- timer : logger . Debug ( " " ) return fmt . Errorf ( " " , timeout ) } err := i . logs . Close ( ) if err != nil { return errors . Wrap ( err , " " ) } return nil }
// Shutdown raft and any raft-related resource we have instantiated.
Shutdown raft and any raft - related resource we have instantiated .