-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
34 lines (28 loc) · 836 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
package main
import (
"context"
"fmt"
"os"
"theskyinflames/graphql-challenge/cmd/service"
"theskyinflames/graphql-challenge/internal/infra/persistence"
"theskyinflames/graphql-challenge/internal/infra/persistence/postgresql"
)
const srvPort = ":80"
func main() {
ctx := context.Background()
db, err := persistence.ConnectToDB(ctx)
if err != nil {
fmt.Println(err.Error())
os.Exit(-1)
}
defer func() {
_ = db.Close()
}()
fmt.Printf("db migration run starting\n")
if err := persistence.RunMigrations(ctx, db, os.Getenv("DB_NAME"), os.Getenv("DB_MIGRATIONS_PATH")); err != nil {
fmt.Printf("something went wrong trying to run database migrations: %s\n", err.Error())
os.Exit(-1)
}
fmt.Printf("db migration run finished\n")
service.Run(context.Background(), srvPort, postgresql.NewProductsRepository(db))
}