lxd/endpoints/endpoints.go
func (e *Endpoints) serveHTTP(kind kind) {
	listener := e.listeners[kind]

	if listener == nil {
		return
	}

	ctx := log.Ctx{"socket": listener.Addr()}
	if e.inherited[kind] {
		ctx["inherited"] = true
	}

	message := fmt.Sprintf(" - binding %s", descriptions[kind])
	logger.Info(message, ctx)

	server := e.servers[kind]

	// Defer the creation of the tomb, so Down() doesn't wait on it unless
	// we actually have spawned at least a server.
	if e.tomb == nil {
		e.tomb = &tomb.Tomb{}
	}

	e.tomb.Go(func() error {
		server.Serve(listener)
		return nil
	})
}
func (e *Endpoints) serveHTTP(kind kind) {
	listener := e.listeners[kind]

	if listener == nil {
		return
	}

	ctx := log.Ctx{"socket": listener.Addr()}
	if e.inherited[kind] {
		ctx["inherited"] = true
	}

	message := fmt.Sprintf(" - binding %s", descriptions[kind])
	logger.Info(message, ctx)

	server := e.servers[kind]

	// Defer the creation of the tomb, so Down() doesn't wait on it unless
	// we actually have spawned at least a server.
	if e.tomb == nil {
		e.tomb = &tomb.Tomb{}
	}

	e.tomb.Go(func() error {
		server.Serve(listener)
		return nil
	})
}
// Start an HTTP server for the endpoint associated with the given code.