-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
47 lines (43 loc) · 1.01 KB
/
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
package main
import (
"github.com/gorilla/handlers"
log "github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
"net/http"
"os"
"strconv"
)
var (
servicePort int
mongoServer string
)
func main() {
app := &cli.App{
Name: "audit-logging-service",
Flags: []cli.Flag{
&cli.IntFlag{
Name: "port",
Value: 4123,
EnvVars: []string{"AUDIT_LOGGING_SERVICE_PORT"},
Destination: &servicePort,
},
&cli.StringFlag{
Name: "mongo-server",
Value: "localhost:27017",
EnvVars: []string{"AUDIT_LOGGING_SERVICE_MONGO_URI"},
Destination: &mongoServer,
},
},
Action: func(context *cli.Context) error {
host := ":" + strconv.Itoa(servicePort)
srv := NewAuditLoggingService()
loggedRouter := handlers.LoggingHandler(os.Stdout, srv.router)
log.Info("Launching new Audit Logging Service on ", host)
return http.ListenAndServe(host, handlers.RecoveryHandler()(loggedRouter))
},
}
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}