-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
43 lines (34 loc) · 955 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
package main
import (
"log"
"github.com/joho/godotenv"
"github.com/BaseMax/real-time-notifications-nats-go/controllers"
"github.com/BaseMax/real-time-notifications-nats-go/database"
"github.com/BaseMax/real-time-notifications-nats-go/models"
"github.com/BaseMax/real-time-notifications-nats-go/notifications"
"github.com/BaseMax/real-time-notifications-nats-go/rabbitmq"
)
func main() {
if err := godotenv.Load(".env"); err != nil {
log.Fatal("godotenv: ", err)
}
c, err := database.ReadConfig()
if err != nil {
log.Fatal("readconfig: ", err)
}
conn, err := database.OpenPostgres(c)
if err != nil {
log.Fatal("open postgres: ", err)
}
if err := models.Init(conn); err != nil {
log.Fatal("models init: ", err)
}
if err := notifications.InitNats(); err != nil {
log.Fatal(err)
}
if err := rabbitmq.Connect(); err != nil {
log.Fatal(err)
}
r := InitRoutes()
r.Logger.Fatal(r.Start(controllers.GetRunningAddr()))
}