Ejemplo n.º 1
0
// serviceStart start service (without attach)
func serviceStart(app string, service string, batch bool) {
	if !batch {
		internal.StreamPrint("GET", fmt.Sprintf("/applications/%s/services/%s/attach", app, service), nil)
	}

	// stream service events in a goroutine
	internal.EventStreamPrint("GET", fmt.Sprintf("/applications/%s/services/%s/events", app, service), nil, true)

	path := fmt.Sprintf("/applications/%s/services/%s/start", app, service)
	buffer, _, err := internal.Stream("POST", path, []byte("{}"))
	internal.Check(err)

	line, err := internal.DisplayStream(buffer)
	internal.Check(err)
	if len(line) > 0 {
		var data map[string]interface{}
		err = json.Unmarshal(line, &data)
		internal.Check(err)

		fmt.Printf("Hostname: %v\n", data["hostname"])
	}

	if !batch {
		internal.ExitAfterCtrlC()
	}
}
Ejemplo n.º 2
0
// serviceScale start service (without attach)
func serviceScale(app string, service string, number int, destroy bool, batch bool) {
	if !batch {
		internal.StreamPrint("GET", fmt.Sprintf("/applications/%s/services/%s/attach", app, service), nil)
	}

	// stream service events in a goroutine
	internal.EventStreamPrint("GET", fmt.Sprintf("/applications/%s/services/%s/events", app, service), nil, true)

	path := fmt.Sprintf("/applications/%s/services/%s/scale", app, service)

	args := Scale{
		Number:  number,
		Destroy: destroy,
	}

	data, err := json.Marshal(&args)
	internal.Check(err)

	buffer, _, err := internal.Stream("POST", path, data)
	internal.Check(err)

	line, err := internal.DisplayStream(buffer)
	internal.Check(err)
	if len(line) > 0 {
		var data map[string]interface{}
		err = json.Unmarshal(line, &data)
		internal.Check(err)

		fmt.Printf("Hostname: %v\n", data["hostname"])
	}

	if !batch {
		internal.ExitAfterCtrlC()
	}
}
Ejemplo n.º 3
0
func serviceEvents(serviceID string) {
	// Split namespace and service
	host, app, service, _, err := internal.ParseResourceName(serviceID)
	internal.Check(err)

	if !internal.CheckHostConsistent(host) {
		fmt.Fprintf(os.Stderr, "Error: Invalid Host %s for endpoint %s\n", host, internal.Host)
		os.Exit(1)
	}

	internal.EventStreamPrint("GET", fmt.Sprintf("/applications/%s/services/%s/events", app, service), nil, false)
	internal.ExitAfterCtrlC()
}