-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
68 lines (63 loc) · 1.5 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package main
import (
"log"
"runtime"
"syscall"
"fmt"
"github.com/judwhite/go-svc/svc"
"github.com/mreiferson/go-options"
"github.com/kppotato/kafka_monitor/g"
"os"
"github.com/BurntSushi/toml"
"github.com/kppotato/kafka_monitor/zookeeper"
"github.com/kppotato/kafka_monitor/http"
"github.com/kppotato/kafka_monitor/cron"
)
func init() {
//log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
runtime.GOMAXPROCS(runtime.NumCPU())
}
type program struct {
}
func (p *program) Init(env svc.Environment) error {
g.Opts = g.NewOption()
flagset := g.SetFlag(g.Opts)
flagset.Parse(os.Args[1:])
configFile :=flagset.Lookup("cfg").Value.String()
var cfg g.Config
if configFile != "" {
_,err :=toml.DecodeFile(configFile,&cfg)
if err != nil {
log.Printf("ERROR: failed to load config file %s - %s\n",configFile,err.Error())
os.Exit(1)
}
}
options.Resolve(g.Opts,flagset,cfg)
zookeeper.Init()
return nil
}
func (p *program) Start() error {
cron.Init()
go http.HttpStart()
go http.HttpPrometheusStart()
//fmt.Println(zookeeper.GetConsumerGroupZK())
//fmt.Println(zookeeper.GetKafkaByZk)
//fmt.Printf("%+v",zookeeper.GetConsumerGroup())
//fmt.Printf("%+v\n",kafka.GetTopicLogSize())
//for _,i :=range ff{
// for _,t :=range i.Topicname{
// g.Logger.Info(t.Name,t.Offset,i.ConsumerGroup)
// }
//}
return nil
}
func (p *program) Stop() error {
return nil
}
func main() {
prg := &program{}
if err := svc.Run(prg, syscall.SIGINT, syscall.SIGTERM); err != nil {
fmt.Println(err)
os.Exit(1)
}
}