forked from helmfile/helmfile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
43 lines (36 loc) · 820 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
package main
import (
"fmt"
"os"
"os/signal"
"syscall"
"github.com/helmfile/helmfile/cmd"
"github.com/helmfile/helmfile/pkg/app"
"github.com/helmfile/helmfile/pkg/config"
"github.com/helmfile/helmfile/pkg/errors"
)
func main() {
var sig os.Signal
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
go func() {
sig = <-sigs
}()
globalConfig := new(config.GlobalOptions)
rootCmd, err := cmd.NewRootCmd(globalConfig)
errors.HandleExitCoder(err)
if err := rootCmd.Execute(); err != nil {
if sig != nil {
fmt.Fprintln(os.Stderr, err)
app.CleanWaitGroup.Wait()
// See http://tldp.org/LDP/abs/html/exitcodes.html
switch sig {
case syscall.SIGINT:
os.Exit(130)
case syscall.SIGTERM:
os.Exit(143)
}
}
errors.HandleExitCoder(err)
}
}