-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
51 lines (38 loc) · 941 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
49
50
51
package main
import (
"os"
"os/signal"
"syscall"
"github.com/edobtc/cloudkit/logging"
"github.com/edobtc/cloudkit/server"
// relay route setup
gateway "github.com/edobtc/cloudkit/gateway/http"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
func init() {
logging.Setup()
}
var rootCmd = &cobra.Command{
Use: "cloudkit-gateway",
Short: "cloudkit-gateway runs a server for intercepting requests to nodes and providing some facility to audit events, add rules etc",
Run: func(cmd *cobra.Command, args []string) {
srv := server.NewServer()
r := srv.Router()
// Account View Handlers
gateway.BindRoutes(r)
signal.Notify(srv.Close, os.Interrupt, syscall.SIGTERM, syscall.SIGINT)
go func() {
s := <-srv.Close
log.Infof("received signal %v", s)
srv.GracefulShutdown()
}()
<-srv.Start()
},
}
func main() {
if err := rootCmd.Execute(); err != nil {
log.Error(err)
os.Exit(1)
}
}