lxd/cluster/gateway.go
func (g *Gateway) Shutdown() error {
	logger.Debugf("Stop database gateway")

	if g.raft != nil {
		err := g.raft.Shutdown()
		if err != nil {
			return errors.Wrap(err, "Failed to shutdown raft")
		}
	}

	if g.server != nil {
		g.Sync()
		g.server.Close()

		// Unset the memory dial, since Shutdown() is also called for
		// switching between in-memory and network mode.
		g.memoryDial = nil
	}

	return nil
}
func (g *Gateway) Shutdown() error {
	logger.Debugf("Stop database gateway")

	if g.raft != nil {
		err := g.raft.Shutdown()
		if err != nil {
			return errors.Wrap(err, "Failed to shutdown raft")
		}
	}

	if g.server != nil {
		g.Sync()
		g.server.Close()

		// Unset the memory dial, since Shutdown() is also called for
		// switching between in-memory and network mode.
		g.memoryDial = nil
	}

	return nil
}
// Shutdown this gateway, stopping the gRPC server and possibly the raft factory.