-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathmain.go
More file actions
96 lines (85 loc) · 2.07 KB
/
main.go
File metadata and controls
96 lines (85 loc) · 2.07 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package main
import (
"fmt"
"os"
"net/http"
"github.com/BaritoLog/barito-flow/cmds"
log "github.com/sirupsen/logrus"
"github.com/urfave/cli"
_ "net/http/pprof"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
const (
Name = "barito-flow"
Version = "0.13.5"
)
var (
Commit string = "N/A"
Build string = "MANUAL"
)
func init() {
log.SetLevel(log.WarnLevel)
}
func main() {
app := cli.App{
Name: Name,
Usage: "Provide kafka producer or consumer for Barito project",
Version: fmt.Sprintf("%s-%s-%s", Version, Build, Commit),
Commands: []cli.Command{
{
Name: "producer",
ShortName: "p",
Usage: "start barito-flow as producer",
Action: cmds.ActionBaritoProducerService,
Flags: []cli.Flag{
cli.BoolFlag{
Name: "verbose, V",
Usage: "Enable verbose mode",
},
},
},
{
Name: "consumer",
ShortName: "c",
Usage: "start barito-flow as consumer",
Action: cmds.ActionBaritoConsumerService,
Flags: []cli.Flag{
cli.BoolFlag{
Name: "verbose, V",
Usage: "Enable verbose mode",
},
},
},
{
Name: "consumer for GCS",
ShortName: "consumer-gcs",
Usage: "start barito-flow as consumer for GCS",
Action: cmds.ActionBaritoConsumerGCSService,
Flags: []cli.Flag{
cli.BoolFlag{
Name: "verbose, V",
Usage: "Enable verbose mode",
},
},
},
},
UsageText: "barito-flow [commands]",
Before: func(c *cli.Context) error {
fmt.Fprintf(os.Stderr, "%s Started. Version: %s Build: %s Commit: %s\n", Name, Version, Build, Commit)
return nil
},
CommandNotFound: func(c *cli.Context, command string) {
fmt.Fprintf(os.Stderr, "Command not found: '%s'. Please use '%s -h' to view usage\n", command, Name)
},
}
http.Handle("/metrics", promhttp.Handler())
exporterPort, exists := os.LookupEnv("EXPORTER_PORT")
if !exists {
exporterPort = ":8008"
}
go http.ListenAndServe(exporterPort, nil)
err := app.Run(os.Args)
if err != nil {
log.Fatalf("Some error occurred: %s", err.Error())
}
}