コード例 #1
0
ファイル: admin.go プロジェクト: carriercomm/sky-1
func StopDaemon(criteria *skynet.Criteria) {
	hosts, err := skynet.GetServiceManager().ListHosts(criteria)

	if err != nil {
		log.Fatal(err)
	}

	var wait sync.WaitGroup

	for _, host := range hosts {
		wait.Add(1)
		go func(host string) {
			d := daemon.GetDaemonForHost(host)

			in := daemon.StopRequest{}
			out, err := d.Stop(in)

			if err != nil {
				fmt.Println("Returned Error: " + err.Error())
				wait.Done()
				return
			}

			if out.Ok {
				fmt.Printf("Daemon stopped on host: %v\n", host)
			} else {
				fmt.Printf("Failed to stop daemon on host: %v\n", host)
			}

			wait.Done()
		}(host)
	}

	wait.Wait()
}
コード例 #2
0
ファイル: admin.go プロジェクト: carriercomm/sky-1
func Start(criteria *skynet.Criteria, args []string) {
	if len(args) < 1 {
		fmt.Println("Please provide a service name 'sky start binaryName'")
		return
	}

	hosts, err := skynet.GetServiceManager().ListHosts(criteria)

	if err != nil {
		log.Fatal(err)
	}

	var wait sync.WaitGroup

	for _, host := range hosts {
		wait.Add(1)
		go func(host string) {
			fmt.Println("Starting on host: " + host)
			d := daemon.GetDaemonForHost(host)

			in := daemon.StartSubServiceRequest{
				BinaryName: args[0],
				Args:       shellquote.Join(args[1:]...),
				// TODO: maybe an optional flag to change this?
				Registered: true,
			}
			out, err := d.StartSubService(in)

			if err != nil {
				fmt.Println("Returned Error: " + err.Error())
				wait.Done()
				return
			}

			startTemplate.Execute(os.Stdout, out)
			wait.Done()
		}(host)
	}

	wait.Wait()
}
コード例 #3
0
ファイル: admin.go プロジェクト: smarinskaya/skynet
// TODO: this should be smarter about which hosts it deploys to
func Deploy(q *skynet.Query, path string, args ...string) {
	cl := client.NewClient(config)

	fmt.Println("deploying " + path + " " + strings.Join(args, ""))

	for _, host := range q.FindHosts() {
		cdaemon := daemon.GetDaemonForHost(cl, host)

		in := daemon.DeployRequest{
			ServicePath: path,
			Args:        shellquote.Join(args...),
		}
		out, err := cdaemon.Deploy(in)

		if err != nil {
			fmt.Println(err)
			return
		}

		deployTemplate.Execute(os.Stdout, out)
	}
}
コード例 #4
0
ファイル: admin.go プロジェクト: carriercomm/sky-1
func SetDaemonLogLevel(criteria *skynet.Criteria, level string) {
	hosts, err := skynet.GetServiceManager().ListHosts(criteria)

	if err != nil {
		log.Fatal(err)
	}

	var wait sync.WaitGroup

	for _, host := range hosts {
		wait.Add(1)
		go func(host string) {
			d := daemon.GetDaemonForHost(host)

			in := daemon.LogLevelRequest{
				Level: level,
			}
			out, err := d.LogLevel(in)

			if err != nil {
				fmt.Println("Returned Error: " + err.Error())
				wait.Done()
				return
			}

			if out.Ok {
				fmt.Printf("Set daemon log level to %v on host: %v\n", level, host)
			} else {
				fmt.Printf("Failed to set daemon log level to %v on host: %v\n", level, host)
			}

			wait.Done()
		}(host)
	}

	wait.Wait()
}