When composer exits, it doesn't wait for the manifest generation goroutines to finish. This is generally a bad practice so let's introduce a bit of syncing and a new Shutdown method to prevent this. This also prevents the manifest generation goroutine from creating weird states when interrupted on a random line of code. Signed-off-by: Ondřej Budai <ondrej@budai.cz>
29 lines
605 B
Go
29 lines
605 B
Go
package cloudapi
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/osbuild/osbuild-composer/internal/distroregistry"
|
|
"github.com/osbuild/osbuild-composer/internal/worker"
|
|
|
|
v2 "github.com/osbuild/osbuild-composer/internal/cloudapi/v2"
|
|
)
|
|
|
|
type Server struct {
|
|
v2 *v2.Server
|
|
}
|
|
|
|
func NewServer(workers *worker.Server, distros *distroregistry.Registry, config v2.ServerConfig) *Server {
|
|
server := &Server{
|
|
v2: v2.NewServer(workers, distros, config),
|
|
}
|
|
return server
|
|
}
|
|
|
|
func (server *Server) V2(path string) http.Handler {
|
|
return server.v2.Handler(path)
|
|
}
|
|
|
|
func (server *Server) Shutdown() {
|
|
server.v2.Shutdown()
|
|
}
|