예제 #1
0
파일: stop.go 프로젝트: KaiYoung/cli
func (s *Stop) Run(c *cli.Context) {
	app := s.appReq.GetApplication()

	if app.State == "stopped" {
		s.ui.Say(term.Magenta("Application " + app.Name + " is already stopped."))
		return
	}

	s.ui.Say("Stopping %s...", term.Cyan(app.Name))

	err := s.appRepo.Stop(app)
	if err != nil {
		s.ui.Failed("Error stopping application.", err)
		return
	}
	s.ui.Ok()
}
예제 #2
0
파일: start.go 프로젝트: KaiYoung/cli
func (s *Start) ApplicationStart(app cf.Application) {
	if app.State == "started" {
		s.ui.Say(term.Magenta("Application " + app.Name + " is already started."))
		return
	}

	s.ui.Say("Starting %s...", term.Cyan(app.Name))

	err := s.appRepo.Start(app)
	if err != nil {
		s.ui.Failed("Error starting application.", err)
		return
	}

	s.ui.Ok()

	instances, errorCode, err := s.appRepo.GetInstances(app)

	for err != nil {
		if errorCode != 170002 {
			s.ui.Say("")
			s.ui.Failed("Error staging application", err)
			return
		}

		s.ui.Wait(1 * time.Second)
		instances, errorCode, err = s.appRepo.GetInstances(app)
		s.ui.LoadingIndication()
	}

	s.ui.Say("")

	s.startTime = time.Now()

	for s.displayInstancesStatus(app, instances) {
		s.ui.Wait(1 * time.Second)
		instances, _, _ = s.appRepo.GetInstances(app)
	}
}
예제 #3
0
파일: target.go 프로젝트: KaiYoung/cli
func (t Target) setNewTarget(target string) {
	t.ui.Say("Setting target to %s...", term.Yellow(target))

	request, err := api.NewRequest("GET", target+"/v2/info", "", nil)

	if err != nil {
		t.ui.Failed("URL invalid.", err)
		return
	}

	scheme := request.URL.Scheme
	if scheme != "http" && scheme != "https" {
		t.ui.Failed("API Endpoints should start with https:// or http://", nil)
		return
	}

	serverResponse := new(InfoResponse)
	_, err = api.PerformRequestAndParseResponse(request, &serverResponse)

	if err != nil {
		t.ui.Failed("", err)
		return
	}

	err = t.saveTarget(target, serverResponse)

	if err != nil {
		t.ui.Failed("Error saving configuration", err)
		return
	}

	t.ui.Ok()

	if scheme == "http" {
		t.ui.Say(term.Magenta("\nWarning: Insecure http API Endpoint detected. Secure https API Endpoints are recommended.\n"))
	}
	t.ui.ShowConfiguration(t.config)
}