This repository has been archived by the owner on Nov 28, 2022. It is now read-only.
/
start.go
62 lines (53 loc) · 1.66 KB
/
start.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
/*******************************************************************************
* Copyright (c) 2019 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package actions
import (
"fmt"
"os"
"github.com/eclipse/codewind-installer/pkg/docker"
"github.com/urfave/cli"
)
// StartCommand : start the codewind containers
func StartCommand(c *cli.Context, dockerComposeFile string, healthEndpoint string) {
dockerClient, dockerErr := docker.NewDockerClient()
if dockerErr != nil {
HandleDockerError(dockerErr)
os.Exit(1)
}
status, err := docker.CheckContainerStatus(dockerClient, docker.LocalCWContainerNames)
if err != nil {
HandleDockerError(err)
os.Exit(1)
}
if status {
fmt.Println("Codewind is already running!")
} else {
tag := c.String("tag")
debug := c.Bool("debug")
loglevel := c.GlobalString("loglevel")
fmt.Println("Debug:", debug)
writeToComposeFileErr := docker.WriteToComposeFile(dockerComposeFile, debug)
if writeToComposeFileErr != nil {
HandleDockerError(writeToComposeFileErr)
os.Exit(1)
}
err := docker.DockerCompose(dockerComposeFile, tag, loglevel)
if err != nil {
HandleDockerError(err)
os.Exit(1)
}
_, pingHealthErr := docker.PingHealth(healthEndpoint)
if pingHealthErr != nil {
HandleDockerError(pingHealthErr)
os.Exit(1)
}
}
}