-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathstart.go
More file actions
39 lines (35 loc) · 840 Bytes
/
start.go
File metadata and controls
39 lines (35 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package client
import (
"fmt"
"os"
"regexp"
"github.com/coreos/fleet/job"
)
// Start launches target units and blocks until active
func (c *FleetClient) Start(target string, data bool) (err error) {
// see if we were provided a specific target
r := regexp.MustCompile(`([a-z-]+)\.([\d]+)`)
match := r.FindStringSubmatch(target)
var component string
if len(match) == 3 {
component = match[1]
} else {
component = target
}
units, err := c.getUnits(component)
if err != nil {
return
}
newState := job.JobStateLaunched
for _, unitName := range units {
err = c.Fleet.SetJobTargetState(unitName, newState)
if err != nil {
return err
}
}
errchan := waitForJobStates(units, testUnitStateActive, 0, os.Stdout)
for err := range errchan {
return fmt.Errorf("error waiting for active: %v", err)
}
return nil
}