-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
48 lines (36 loc) · 989 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
package main
import (
"highload-arch/pkg/backend"
"highload-arch/pkg/config"
"highload-arch/pkg/storage"
"log"
"net/http"
"os"
)
func setLoggerFile(filename string) *os.File {
f, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
if err != nil {
log.Fatalf("error opening file: %v", err)
}
log.SetOutput(f)
return f
}
func main() {
/*f := setLoggerFile("./logs/service.log")
defer f.Close()*/
config.Load("local-config.yaml")
log.Println("Connecting to Postgres")
storage.CreateConnectionPool()
storage.CreateReplicaConnectionPool()
log.Println("Connecting to Cache")
storage.ConnectToCache()
//log.Printf("Connecting to TT")
//storage.ConnectToTarantool()
//defer storage.CloseTarantoolConnection()
log.Printf("Connecting to RabbitMQ")
storage.ConnectToRabbitMQ()
defer storage.CloseRabbitMQ()
log.Printf("Server started")
router := backend.NewRouter()
log.Fatal(http.ListenAndServe(config.GetString("server.port"), router))
}