/
stop.go
46 lines (38 loc) 路 1.05 KB
/
stop.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
package cli
import (
"fmt"
"os"
"path/filepath"
"github.com/krzko/run-o11y-run/internal/files"
"github.com/urfave/cli/v2"
)
// genStopCommand generates the stop command
func genStopCommand() *cli.Command {
return &cli.Command{
Name: "stop",
Usage: "Stop run-o11y-run containers",
Aliases: []string{"t"},
Action: func(c *cli.Context) error {
fmt.Printf("馃弫 Stopping...\n\n")
if !checkDockerAvailability() {
fmt.Println("Docker command not found. Please make sure Docker is installed and available in your PATH.")
os.Exit(1)
}
homeDir := getHomeDir()
targetDir := filepath.Join(homeDir, ".run-o11y-run")
err := files.ExtractFiles(targetDir, files.ServicesConfig{})
if err != nil {
fmt.Println("Error extracting files:", err)
return err
}
err = runDockerCompose(filepath.Join(targetDir, "files", "grafana", "run-o11y-run"), "down")
if err != nil {
fmt.Println("Error running docker compose down:", err)
return err
}
// os.Exit(0)
fmt.Printf("\n馃弫 Stopped\n\n")
return nil
},
}
}