forked from deis/deis
/
platform.go
102 lines (71 loc) · 2.16 KB
/
platform.go
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package cmd
import (
"fmt"
"sync"
"time"
"github.com/deis/deis/deisctl/backend"
"github.com/deis/deis/deisctl/utils"
)
// InstallPlatform loads all components' definitions from local unit files.
// After InstallPlatform, all components will be available for StartPlatform.
func InstallPlatform(b backend.Backend) error {
if err := checkRequiredKeys(); err != nil {
return err
}
outchan := make(chan string)
errchan := make(chan error)
var wg sync.WaitGroup
go printState(outchan, errchan, 500*time.Millisecond)
outchan <- utils.DeisIfy("Installing Deis...")
installDefaultServices(b, &wg, outchan, errchan)
wg.Wait()
close(outchan)
fmt.Println("Done.")
fmt.Println()
fmt.Println("Please run `deisctl start platform` to boot up Deis.")
return nil
}
// StartPlatform activates all components.
func StartPlatform(b backend.Backend) error {
outchan := make(chan string)
errchan := make(chan error)
var wg sync.WaitGroup
go printState(outchan, errchan, 500*time.Millisecond)
outchan <- utils.DeisIfy("Starting Deis...")
startDefaultServices(b, &wg, outchan, errchan)
wg.Wait()
close(outchan)
fmt.Println("Done.")
fmt.Println()
fmt.Println("Please use `deis register` to setup an administrator account.")
return nil
}
// StopPlatform deactivates all components.
func StopPlatform(b backend.Backend) error {
outchan := make(chan string)
errchan := make(chan error)
var wg sync.WaitGroup
go printState(outchan, errchan, 500*time.Millisecond)
outchan <- utils.DeisIfy("Stopping Deis...")
stopDefaultServices(b, &wg, outchan, errchan)
wg.Wait()
close(outchan)
fmt.Println("Done.")
fmt.Println()
fmt.Println("Please run `deisctl start platform` to restart Deis.")
return nil
}
// UninstallPlatform unloads all components' definitions.
// After UninstallPlatform, all components will be unavailable.
func UninstallPlatform(b backend.Backend) error {
outchan := make(chan string)
errchan := make(chan error)
var wg sync.WaitGroup
go printState(outchan, errchan, 500*time.Millisecond)
outchan <- utils.DeisIfy("Uninstalling Deis...")
uninstallAllServices(b, &wg, outchan, errchan)
wg.Wait()
close(outchan)
fmt.Println("Done.")
return nil
}