41 lines
988 B
Go
41 lines
988 B
Go
package libpod
|
|
|
|
import (
|
|
"log"
|
|
"net"
|
|
|
|
"github.com/containers/podman/v5/cmd/podman/registry"
|
|
api "github.com/containers/podman/v5/pkg/api/server"
|
|
"github.com/containers/podman/v5/pkg/domain/entities"
|
|
"github.com/containers/podman/v5/pkg/domain/infra"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func NewServer() {
|
|
cmd := &cobra.Command{}
|
|
cfg := registry.PodmanConfig()
|
|
defaultConf := cfg.ContainersConfDefaultsRO
|
|
defaultConf.Engine.OCIRuntime = Defaultruntime
|
|
setupRuntime(cfg)
|
|
persistentPreRunE(cmd, nil)
|
|
libpodRuntime, err := infra.GetRuntime(registry.Context(), cmd.PersistentFlags(), cfg)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
listener, err := net.Listen("tcp", "127.0.0.1:8888")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
libpodRuntime.SetRemoteURI("tcp://localhost:8888")
|
|
infra.StartWatcher(libpodRuntime)
|
|
|
|
server, err := api.NewServerWithSettings(libpodRuntime, listener, entities.ServiceOptions{
|
|
URI: "tcp://localhost:8888",
|
|
})
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
go server.Serve()
|
|
}
|