コード例 #1
0
ファイル: cl-manager.go プロジェクト: elleFlorio/gru
func (m *Manager) stopService(what string, where []string) {
	var err error
	nodes := cluster.ListNodes(m.Cluster, false)
	if where[0] == "all" {
		for name, addr := range nodes {
			err = network.SendStopServiceCommand(addr, what)
			if err != nil {
				fmt.Println("Error sending start service command to node ", name)
			}
		}
	} else {
		for _, node := range where {
			if addr, ok := nodes[node]; ok {
				err = network.SendStopServiceCommand(addr, what)
				if err != nil {
					fmt.Println("Error sending start service command to node ", node)
				}
			} else {
				fmt.Println("Cannot get address of node ", node)
			}
		}
	}
}
コード例 #2
0
ファイル: cl-manager.go プロジェクト: elleFlorio/gru
func (m *Manager) undeploy() {
	if !m.isClusterSet() {
		return
	}

	var err error
	w := new(tabwriter.Writer)
	w.Init(os.Stdout, 0, 8, 1, '\t', 0)
	fmt.Fprintf(w, "NODE\tSTATUS\n")

	services := cluster.ListServices(m.Cluster)
	nodes := cluster.ListNodes(m.Cluster, false)
	for node, address := range nodes {
		status := "done"
		err = network.SendUpdateCommand(address, "node-base-services", []string{})
		if err != nil {
			fmt.Println("Error sending update command to ", address)
			status = "error"
		}

		for service, _ := range services {
			err = network.SendStopServiceCommand(address, service)
			if err != nil {
				fmt.Println("Error sending stop service command to node ", node)
				status = "error"
			}
		}

		fmt.Fprintf(w, "%s\t%s\n",
			node,
			status,
		)
	}

	w.Flush()
}