-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
59 lines (51 loc) · 1.37 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
package main
import (
"fmt"
"github.com/joho/godotenv"
//"github.com/joho/godotenv"
//"github.com/joho/godotenv"
//"github.com/pkg/profile"
"github.com/prometheus/client_golang/prometheus/promhttp"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
"log"
"net"
"net/http"
pb "therealbroker/api/proto"
"therealbroker/api/server"
//"runtime"
_ "net/http/pprof"
)
func main() {
err := godotenv.Load()
if err != nil {
fmt.Println("couldn't load file")
}
//defer profile.Start(profile.CPUProfile, profile.ProfilePath(".")).Stop()
//defer profile.Start(profile.MemProfile,profile.MemProfileRate(1), profile.ProfilePath(".")).Stop()
//defer profile.Start(profile.TraceProfile, profile.ProfilePath(".")).Stop()
go func(){
fmt.Println("starting prometheus on 8000")
http.Handle("/metrics",promhttp.Handler())
err := http.ListenAndServe(":8000", nil)
if err != nil {
fmt.Println(err)
}
}()
//go func() {
// http.ListenAndServe(":8080",nil)
//}()
lis, err := net.Listen("tcp", ":8086")
if err != nil {
log.Fatalf("failed to listen: %v", err)
}
var opts []grpc.ServerOption
grpcServer := grpc.NewServer(opts...)
pb.RegisterBrokerServer(grpcServer,server.GetServer())
fmt.Println("starting grpc server on 8086")
reflection.Register(grpcServer)
err = grpcServer.Serve(lis)
if err != nil {
log.Fatalf("failed to run server: %v\n", err)
}
}