-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrolling_restart.go
More file actions
37 lines (33 loc) · 801 Bytes
/
Copy pathrolling_restart.go
File metadata and controls
37 lines (33 loc) · 801 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
package fleet
import (
"fmt"
"io"
"sync"
)
// RollingRestart for instance units
func (c *FleetClient) RollingRestart(component string, wg *sync.WaitGroup, out, ew io.Writer) {
if component != "router" {
fmt.Fprint(ew, "invalid component. supported for: router")
return
}
components, err := c.Units(component)
if err != nil {
io.WriteString(ew, err.Error())
return
}
if len(components) < 1 {
fmt.Fprint(ew, "rolling restart requires at least 1 component")
return
}
for num := range components {
unitName := fmt.Sprintf("%s@%v", component, num+1)
c.Stop([]string{unitName}, wg, out, ew)
wg.Wait()
c.Destroy([]string{unitName}, wg, out, ew)
wg.Wait()
c.Create([]string{unitName}, wg, out, ew)
wg.Wait()
c.Start([]string{unitName}, wg, out, ew)
wg.Wait()
}
}