-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
48 lines (40 loc) · 847 Bytes
/
main.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
/*
Copyright © 2023 github.com/m4schini
*/
package main
import (
"go.uber.org/zap"
"os"
"path/filepath"
"roci/cmd"
"roci/pkg/logger"
)
func main() {
//s := strings.Join(os.Args, " ")
//fmt.Println(s)
//util.DebugLogToFile(s)
defer logger.Sync()
if isInitProcess() {
executeInit()
} else {
executeCLI()
}
}
func isInitProcess() bool {
return len(os.Args) == 3 && os.Args[1] == cmd.InitCommandName
}
func executeInit() {
logger.Set(logger.Log().Named("init").With(zap.String("cid", filepath.Base(os.Args[2]))))
log := logger.Log()
log.Debug("running container init")
err := cmd.ExecuteInit(os.Args[2])
if err != nil {
log.Fatal("failed to run container init", zap.Error(err))
}
}
func executeCLI() {
logger.Set(logger.Log().Named("main"))
log := logger.Log()
log.Debug("running runtime cli")
cmd.ExecuteCLI()
}