-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.go
44 lines (37 loc) · 1.2 KB
/
start.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
package cmd
import (
"github.com/spf13/cobra"
"github.com/visheyra/prometheus-nats-gateway/prom"
"go.uber.org/zap"
)
var forward = ""
var listen = ""
var user = ""
var pass = ""
var topic = ""
var startCmd = &cobra.Command{
Use: "start",
Short: "Start the tool",
Long: "Start png with specified configuration",
Run: func(cmd *cobra.Command, args []string) {
l, err := zap.NewProduction()
if err != nil {
return
}
defer l.Sync()
logger := l.Sugar()
logger.Infow("Starting server",
"listen", listen,
"forward", forward,
)
prom.StartServer(listen, forward, user, pass, topic)
},
}
func init() {
rootCmd.AddCommand(startCmd)
rootCmd.PersistentFlags().StringVarP(&listen, "listen", "l", ":8080", "listen address of the prometheus receiver endpoint")
rootCmd.PersistentFlags().StringVarP(&forward, "forward", "f", "http://localhost:4222", "address of the remote nats endpoint")
rootCmd.PersistentFlags().StringVarP(&user, "user", "u", "user", "user to authenticate to nats endpoint")
rootCmd.PersistentFlags().StringVarP(&pass, "password", "p", "password", "password for nats endpoint")
rootCmd.PersistentFlags().StringVarP(&topic, "topic", "t", "default", "topic on which subscribe")
}