summaryrefslogtreecommitdiff
path: root/cmd/service/main.go
blob: 0290de892c565a4839757d4765c255f06e3c4448 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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)
	}
}