diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-01-10 21:28:05 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-10 21:28:05 +0100 |
commit | e1ffac6cc73eb36640cbaf6a1a28ba44749a96d9 (patch) | |
tree | 61134dad4b2efdaa65dee6e7206e5ce20080302c /cmd/service | |
parent | 6ed88e047579bd2d1eac99a6089cc617f0c4773d (diff) | |
parent | 986feef2e80cfaed7cbce0df4fd5d619bcffefd7 (diff) | |
download | podman-e1ffac6cc73eb36640cbaf6a1a28ba44749a96d9.tar.gz podman-e1ffac6cc73eb36640cbaf6a1a28ba44749a96d9.tar.bz2 podman-e1ffac6cc73eb36640cbaf6a1a28ba44749a96d9.zip |
Merge pull request #4832 from baude/apiv2tomaster
Apiv2tomaster
Diffstat (limited to 'cmd/service')
-rw-r--r-- | cmd/service/main.go | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/cmd/service/main.go b/cmd/service/main.go new file mode 100644 index 000000000..0290de892 --- /dev/null +++ b/cmd/service/main.go @@ -0,0 +1,55 @@ +package main + +import ( + "context" + "fmt" + "os" + + "github.com/containers/libpod/cmd/podman/cliconfig" + "github.com/containers/libpod/cmd/podman/libpodruntime" + api "github.com/containers/libpod/pkg/api/server" + "github.com/containers/storage/pkg/reexec" + log "github.com/sirupsen/logrus" + "github.com/spf13/cobra" +) + +func initConfig() { + // we can do more stuff in here. +} + +func main() { + if reexec.Init() { + // We were invoked with a different argv[0] indicating that we + // had a specific job to do as a subprocess, and it's done. + return + } + + cobra.OnInitialize(initConfig) + log.SetLevel(log.DebugLevel) + + config := cliconfig.PodmanCommand{ + Command: &cobra.Command{}, + InputArgs: []string{}, + GlobalFlags: cliconfig.MainFlags{}, + Remote: false, + } + // Create a single runtime for http + runtime, err := libpodruntime.GetRuntimeDisableFDs(context.Background(), &config) + if err != nil { + fmt.Printf("error creating libpod runtime: %s", err.Error()) + os.Exit(1) + } + defer runtime.DeferredShutdown(false) + + server, err := api.NewServer(runtime) + if err != nil { + fmt.Println(err.Error()) + os.Exit(1) + } + + err = server.Serve() + if err != nil { + fmt.Println(err.Error()) + os.Exit(1) + } +} |