-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
47 lines (44 loc) · 1022 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
package main
import (
"github.com/504dev/logr/clickhouse"
"github.com/504dev/logr/config"
"github.com/504dev/logr/logger"
"github.com/504dev/logr/models/count"
"github.com/504dev/logr/models/log"
"github.com/504dev/logr/models/ws"
"github.com/504dev/logr/mysql"
"github.com/504dev/logr/server"
"github.com/fatih/color"
"os"
"os/signal"
"time"
)
func main() {
color.NoColor = false
args := config.Init()
clickhouse.Init(args.Retries)
mysql.Init(args.Retries)
logger.Init()
log.RunQueue() // TODO graceful shutdown
count.RunQueue() // TODO graceful shutdown
go server.MustListenUDP()
go server.MustListenGRPC()
go server.MustListenHTTP()
go server.MustListenPROM()
go (func() {
for {
time.Sleep(10 * time.Second)
logger.Logger.Info("ws.SockMap %v", ws.SockMap.String())
}
})()
HandleExit()
}
func HandleExit() {
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
sig := <-c
logger.Logger.Warn("Exit with code: %v", sig)
log.StopQueue()
count.StopQueue()
os.Exit(0)
}