Пример #1
0
func startUnitAction(c *cli.Context) {
	r := getRegistry(c)

	cliRequirements := parseRequirements(c.String("require"))

	payloads := make([]job.JobPayload, len(c.Args()))
	for i, v := range c.Args() {
		out, err := ioutil.ReadFile(v)
		if err != nil {
			fmt.Printf("%s: No such file or directory\n", v)
			return
		}

		unitFile := unit.NewSystemdUnitFile(string(out))
		fileRequirements := unitFile.Requirements()
		requirements := stackRequirements(fileRequirements, cliRequirements)

		name := path.Base(v)
		payload, err := job.NewJobPayload(name, unitFile.String(), requirements)
		if err != nil {
			fmt.Println(err.Error())
			return
		} else {
			payloads[i] = *payload
		}
	}

	req, err := job.NewJobRequest(payloads)
	if err != nil {
		fmt.Println(err.Error())
		return
	}

	r.AddRequest(req)
}
Пример #2
0
func startUnitAction(c *cli.Context) {
	r := registry.New()

	payloads := make([]job.JobPayload, len(c.Args()))

	for i, v := range c.Args() {
		out, err := ioutil.ReadFile(v)
		if err != nil {
			fmt.Printf("%s: No such file or directory\n", v)
		}

		name := path.Base(v)
		payload := job.JobPayload{name, string(out)}
		if err != nil {
			fmt.Print(err)
		} else {
			payloads[i] = payload
		}
	}

	//TODO: Handle error response from NewJobRequest
	req, _ := job.NewJobRequest(payloads, nil)

	if c.Bool("all-machines") {
		req.SetFlag(job.RequestAllMachines)
		req.Count = 1
	} else {
		req.Count = c.Int("count")
	}

	r.AddRequest(req)
}