|
7 | 7 | "fmt" |
8 | 8 | "github.com/coreos/go-omaha/omaha" |
9 | 9 | update "github.com/coreos/updatectl/client/update/v1" |
| 10 | + "github.com/deis/deisctl/client" |
| 11 | + "github.com/deis/deisctl/cmd" |
10 | 12 | "github.com/deis/deisctl/utils" |
11 | 13 | "io" |
12 | 14 | "log" |
@@ -102,7 +104,37 @@ func (c *Client) updateservice() { |
102 | 104 | fmt.Println("starting systemd units") |
103 | 105 | files, _ := utils.ListFiles(downloadDir + "*.service") |
104 | 106 | fmt.Println(files) |
| 107 | + deis, err := client.NewClient() |
| 108 | + localServices := deis.GetLocaljobs() |
| 109 | + Services := utils.GetServices() |
| 110 | + if len(localService) == 0 { |
| 111 | + fmt.Println("no local services") |
| 112 | + return |
| 113 | + } |
| 114 | + for _, service := range localServices { |
| 115 | + cmd.Unisntall(deis, strings.Split(strings.Split(service, "-")[1], ".")[0]) |
| 116 | + cmd.Install(deis, strings.Split(strings.Split(service, "-")[1], ".")[0]) |
| 117 | + } |
| 118 | + var count int |
| 119 | + for _, service := range Services { |
| 120 | + count = 0 |
| 121 | + for _, lserv := range localServices { |
| 122 | + if strings.Contains(lserv, strings.Split(strings.Split(service, "-")[1], ".")[0]) { |
| 123 | + count = count + 1 |
| 124 | + } |
| 125 | + } |
| 126 | + if count == 0 { |
| 127 | + go func() { |
| 128 | + cmd.PullImage(service) |
| 129 | + }() |
| 130 | + } |
| 131 | + } |
105 | 132 |
|
| 133 | + // pre-install hook (download all new docker images) |
| 134 | + // use systemd to list local deis-* units, ignore -data units |
| 135 | + // cmd.Unistall([]string{"router.3"}) |
| 136 | + // cmd.Install([]string{"router.3"}) |
| 137 | + // post-install hook (make sure upgrade was successful) |
106 | 138 | } |
107 | 139 |
|
108 | 140 | func (c *Client) downloadFromUrl(url, fileName string) (err error) { |
|
0 commit comments