2015-12-02 22:41:49 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/Sirupsen/logrus"
|
|
|
|
"github.com/codegangsta/cli"
|
|
|
|
"github.com/docker/containerd"
|
|
|
|
)
|
|
|
|
|
|
|
|
const Usage = `High performance conatiner daemon controller`
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
app := cli.NewApp()
|
|
|
|
app.Name = "ctr"
|
|
|
|
app.Version = containerd.Version
|
|
|
|
app.Usage = Usage
|
|
|
|
app.Authors = []cli.Author{
|
|
|
|
{
|
|
|
|
Name: "@crosbymichael",
|
|
|
|
Email: "crosbymichael@gmail.com",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
app.Flags = []cli.Flag{
|
|
|
|
cli.BoolFlag{
|
|
|
|
Name: "debug",
|
|
|
|
Usage: "enable debug output in the logs",
|
|
|
|
},
|
|
|
|
cli.StringFlag{
|
2015-12-14 23:54:11 +00:00
|
|
|
Name: "address",
|
|
|
|
Value: "/run/containerd/containerd.sock",
|
|
|
|
Usage: "address of GRPC API",
|
2015-12-02 22:41:49 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
app.Commands = []cli.Command{
|
2015-12-10 01:03:53 +00:00
|
|
|
CheckpointCommand,
|
2015-12-11 01:07:21 +00:00
|
|
|
ContainersCommand,
|
2015-12-10 20:30:04 +00:00
|
|
|
EventsCommand,
|
2015-12-02 22:41:49 +00:00
|
|
|
}
|
|
|
|
app.Before = func(context *cli.Context) error {
|
|
|
|
if context.GlobalBool("debug") {
|
|
|
|
logrus.SetLevel(logrus.DebugLevel)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
if err := app.Run(os.Args); err != nil {
|
|
|
|
logrus.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func fatal(err string, code int) {
|
2015-12-10 01:03:53 +00:00
|
|
|
fmt.Fprintf(os.Stderr, "[ctr] %s\n", err)
|
2015-12-02 22:41:49 +00:00
|
|
|
os.Exit(code)
|
|
|
|
}
|