Пример #1
0
func currentRack(c *cli.Context) string {
	cr, err := ioutil.ReadFile(filepath.Join(ConfigRoot, "rack"))
	if err != nil && !os.IsNotExist(err) {
		stdcli.Error(err)
	}

	return coalesce(c.String("rack"), os.Getenv("CONVOX_RACK"), stdcli.ReadSetting("rack"), strings.TrimSpace(string(cr)))
}
Пример #2
0
func cmdStart(c *cli.Context) {
	cache := !c.Bool("no-cache")

	wd := "."

	if len(c.Args()) > 0 {
		wd = c.Args()[0]
	}

	dir, app, err := stdcli.DirApp(c, wd)

	if err != nil {
		stdcli.Error(err)
		return
	}

	file := c.String("file")

	m, err := manifest.Read(dir, file)

	if err != nil {
		changes, err := manifest.Init(dir)

		if err != nil {
			stdcli.Error(err)
			return
		}

		fmt.Printf("Generated: %s\n", strings.Join(changes, ", "))

		m, err = manifest.Read(dir, file)

		if err != nil {
			stdcli.Error(err)
			return
		}
	}

	conflicts, err := m.PortConflicts()

	if err != nil {
		stdcli.Error(err)
		return
	}

	if len(conflicts) > 0 {
		stdcli.Error(fmt.Errorf("ports in use: %s", strings.Join(conflicts, ", ")))
		return
	}

	missing, err := m.MissingEnvironment(cache)

	if err != nil {
		stdcli.Error(err)
		return
	}

	if len(missing) > 0 {
		stdcli.Error(fmt.Errorf("env expected: %s", strings.Join(missing, ", ")))
		return
	}

	errors := m.Build(app, dir, cache)

	if len(errors) != 0 {
		fmt.Printf("errors: %+v\n", errors)
		return
	}

	ch := make(chan []error)

	go func() {
		ch <- m.Run(app, cache)
	}()

	if c.Bool("sync") && stdcli.ReadSetting("sync") != "false" {
		m.Sync(app)
	}

	errors = <-ch

	if len(errors) != 0 {
		// TODO figure out what to do here
		// fmt.Printf("errors: %+v\n", errors)
		return
	}
}