Exemplo n.º 1
0
func main() {
	// solution for https://github.com/golang/go/issues/6785
	http.DefaultTransport.(*http.Transport).MaxIdleConnsPerHost = 100

	app := cli.NewApp()
	app.Name = "gracevisord"
	app.Usage = "gracevisor daemon"
	app.Email = "*****@*****.**"
	app.Version = version
	app.Flags = []cli.Flag{
		cli.StringFlag{
			Name:  "conf",
			Value: defaultConfigDir,
			Usage: "path to config dir",
		},
	}
	app.Action = func(c *cli.Context) {
		config, err := ParseConfing(c.String("conf"))
		if err != nil {
			log.Fatal(err)
		}

		configureGracevisorLogger(config.Logger)
		startApp(config)
	}
	app.Run(os.Args)
}
Exemplo n.º 2
0
func main() {
	app := cli.NewApp()
	app.Name = "gracevisorctl"
	app.Usage = "Manage gracevisord"
	app.Email = "*****@*****.**"
	app.Version = version
	app.Flags = []cli.Flag{
		cli.StringFlag{
			Name:  "host",
			Value: defaultHost,
			Usage: "daemon host",
		},
		cli.IntFlag{
			Name:  "port",
			Value: defaultPort,
			Usage: "daemon port",
		},
	}

	app.Commands = []cli.Command{
		{
			Name:  "status",
			Usage: "display application status",
			Action: func(c *cli.Context) {
				statusRpcCall(getRpcClient(c), c.Args().First())
			},
		},
		{
			Name:  "restart",
			Usage: "restart application",
			Action: func(c *cli.Context) {
				basicRpcCall(getRpcClient(c), "Restart", c.Args().First())
			},
		},
		{
			Name:  "start",
			Usage: "start application",
			Action: func(c *cli.Context) {
				basicRpcCall(getRpcClient(c), "Start", c.Args().First())
			},
		},
		{
			Name:  "stop",
			Usage: "stop running instances",
			Action: func(c *cli.Context) {
				basicRpcCall(getRpcClient(c), "Stop", c.Args().First())
			},
		},
		{
			Name:  "kill",
			Usage: "kill running instances",
			Action: func(c *cli.Context) {
				basicRpcCall(getRpcClient(c), "Kill", c.Args().First())
			},
		},
	}

	app.Run(os.Args)
}