Example #1
0
File: apps.go Project: convox/rack
func cmdAppCreate(c *cli.Context) error {
	_, app, err := stdcli.DirApp(c, ".")
	if err != nil {
		return stdcli.Error(err)
	}

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

	if app == "" {
		return stdcli.Error(fmt.Errorf("must specify an app name"))
	}

	stdcli.Startf("Creating app <app>%s</app>", app)

	_, err = rackClient(c).CreateApp(app)
	if err != nil {
		return stdcli.Error(err)
	}

	stdcli.Wait("CREATING")

	if c.Bool("wait") {
		stdcli.Startf("Waiting for <app>%s</app>", app)

		if err := waitForAppRunning(c, app); err != nil {
			stdcli.Error(err)
		}

		stdcli.OK()
	}

	return nil
}
Example #2
0
File: apps.go Project: convox/rack
func cmdAppDelete(c *cli.Context) error {
	if len(c.Args()) < 1 {
		stdcli.Usage(c, "delete")
		return nil
	}

	app := c.Args()[0]

	stdcli.Startf("Deleting <app>%s</app>", app)

	_, err := rackClient(c).DeleteApp(app)
	if err != nil {
		return stdcli.Error(err)
	}

	stdcli.Wait("DELETING")

	return nil
}
Example #3
0
File: apps.go Project: convox/rack
func cmdAppCancel(c *cli.Context) error {
	_, app, err := stdcli.DirApp(c, ".")
	if err != nil {
		return stdcli.Error(err)
	}

	if app == "" {
		return stdcli.Error(fmt.Errorf("must specify an app name"))
	}

	stdcli.Startf("Cancelling update for <app>%s</app>", app)

	if err := rackClient(c).CancelApp(app); err != nil {
		return stdcli.Error(err)
	}

	stdcli.Wait("CANCELLED")

	return nil
}
Example #4
0
File: rack.go Project: convox/rack
func cmdRackUpdate(c *cli.Context) error {
	vs, err := version.All()
	if err != nil {
		return stdcli.Error(err)
	}

	target, err := vs.Latest()
	if err != nil {
		return stdcli.Error(err)
	}

	if len(c.Args()) > 0 {
		t, err := vs.Find(c.Args()[0])
		if err != nil {
			return stdcli.Error(err)
		}
		target = t
	}

	system, err := rackClient(c).GetSystem()
	if err != nil {
		return stdcli.Error(err)
	}

	nv, err := vs.Next(system.Version)
	if err != nil && strings.HasSuffix(err.Error(), "is latest") {
		nv = target.Version
	} else if err != nil {
		return stdcli.Error(err)
	}

	next, err := vs.Find(nv)
	if err != nil {
		return stdcli.Error(err)
	}

	// stop at a required release if necessary
	if next.Version < target.Version {
		stdcli.Writef("WARNING: Required update found.\nPlease run `convox rack update` again once this update completes.\n")
		target = next
	}

	stdcli.Startf("Updating to <release>%s</release>", target.Version)

	_, err = rackClient(c).UpdateSystem(target.Version)
	if err != nil {
		return stdcli.Error(err)
	}

	stdcli.Wait("UPDATING")

	if c.Bool("wait") {
		stdcli.Startf("Waiting for completion")

		// give the rack a few seconds to start updating
		time.Sleep(5 * time.Second)

		if err := waitForRackRunning(c); err != nil {
			return stdcli.Error(err)
		}

		stdcli.OK()
	}

	return nil
}