-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
36 lines (31 loc) · 783 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
package main
import (
"context"
"github.com/jlehtimaki/aws-shield-controller/controller"
"github.com/jlehtimaki/aws-shield-controller/pkg/apis/awsshield"
log "github.com/sirupsen/logrus"
"os"
"os/signal"
"syscall"
)
func main() {
cfg := awsshield.NewConfig()
if err := cfg.ParseFlags(os.Args[1:]); err != nil {
log.Fatalf("flag parsing error: %v", err)
}
log.Infof("Check interval: %s", cfg.Interval)
ctrl := controller.Controller{
Interval: cfg.Interval,
}
ctx, cancel := context.WithCancel(context.Background())
go handleSigterm(cancel)
log.Info("Running")
ctrl.Run(ctx)
}
func handleSigterm(cancel func()) {
signals := make(chan os.Signal, 1)
signal.Notify(signals, syscall.SIGTERM)
<-signals
log.Info("Received SIGTERM. Terminating...")
cancel()
}