예제 #1
0
func runAction(c *cli.Context) {
	initLoggers(c)

	dockerClient, host, err := utils.GetDockerCient(c)
	if err != nil {
		os.Exit(1)
	}

	redisClient, err := utils.GetRedisClient(c)
	if err != nil {
		os.Exit(1)
	}

	cmd := []string{c.Args().First()}
	cmd = append(cmd, c.Args().Tail()...)
	if len(cmd) < 4 {
		logs.Error.Println("Incorrect usage, please check --help")
		return
	}
	group := cmd[0]
	conn := cmd[1]
	image := cmd[2]
	t := cmd[3]
	timeout, err := strconv.Atoi(t)
	if err != nil {
		// handle error
		logs.Error.Println(err)
		os.Exit(2)
	}
	cmd = cmd[4:]
	logs.Debug.Println("Launching " + image + " " + strings.Join(cmd, " "))
	logs.Warning.Printf("In command line, connector schedule is not available")
	intools.Engine = &intools.IntoolsEngineImpl{dockerClient, host, redisClient, nil}
	connector := connectors.NewConnector(group, conn)
	connector.Init(image, timeout, 0, cmd)
	groups.CreateGroup(group)
	if err != nil {
		os.Exit(3)
	}
	executor, err := connectors.Exec(connector)
	if err != nil {
		os.Exit(3)
	}
	fmt.Println(executor.GetJSON())

}
예제 #2
0
func daemonAction(c *cli.Context) {
	initLoggers(c)
	port := c.GlobalInt("port")
	debug := c.GlobalBool("debug")
	logs.Trace.Println("Starting Intools-Engine as daemon")

	dockerClient, dockerHost, err := utils.GetDockerCient(c)
	if err != nil {
		os.Exit(1)
	}

	redisClient, err := utils.GetRedisClient(c)
	if err != nil {
		os.Exit(1)
	}

	d := server.NewDaemon(port, debug, dockerClient, dockerHost, redisClient)
	d.SetRoutes()
	d.Run()
}