-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
62 lines (50 loc) · 998 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package main
import (
"context"
"fmt"
"greet_gin/config"
"greet_gin/database"
"greet_gin/routers"
"net/http"
_ "net/http/pprof"
"runtime"
"time"
_ "github.com/mkevac/debugcharts"
"github.com/sirupsen/logrus"
)
func dummyCPUUsage() {
var a uint64
var t = time.Now()
for {
t = time.Now()
a += uint64(t.Unix())
}
}
func dummyAllocations() {
var d []uint64
for {
for i := 0; i < 2*1024*1024; i++ {
d = append(d, 42)
}
time.Sleep(time.Second * 10)
fmt.Println(len(d))
d = make([]uint64, 0)
runtime.GC()
time.Sleep(time.Second * 10)
}
}
func main() {
go dummyAllocations()
go dummyCPUUsage()
go func() {
logrus.Info(http.ListenAndServe(":10108", nil))
}()
config.Setup()
database.Init()
database.InitES()
fmt.Println("es client", database.GetElasticClient(context.Background()))
database.RabbitMqInit()
fmt.Println("rabbitMq init successful:", database.GetRabbitMqConn())
r := routers.InitRouter()
r.Run(":" + config.ServerSetting.Port)
}