-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
39 lines (34 loc) · 1.17 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
package main
import (
"github.com/ehsandavari/go-clean-architecture/application"
"github.com/ehsandavari/go-clean-architecture/infrastructure"
"github.com/ehsandavari/go-clean-architecture/persistence"
"github.com/ehsandavari/go-clean-architecture/presentation"
"github.com/ehsandavari/go-graceful-shutdown"
"github.com/joho/godotenv"
"log"
"time"
)
func main() {
loadEnv()
run()
}
func loadEnv() {
if err := godotenv.Load(); err != nil {
log.Fatalln("error in loading .env file", err)
}
}
func run() {
newInfrastructure := infrastructure.NewInfrastructure()
newPersistence := persistence.NewPersistence(newInfrastructure.ILogger, newInfrastructure.SPostgres)
application.NewApplication(newInfrastructure.SConfig, newInfrastructure.ILogger, newInfrastructure.ITracer, newPersistence.UnitOfWork).Setup()
newPresentation := presentation.NewPresentation(newInfrastructure.SConfig, newInfrastructure.ILogger)
newPresentation.Setup()
shutdownFunc := func() {
newPresentation.Close()
}
cleanupFunc := func() {
newInfrastructure.Close()
}
graceful.Shutdown(shutdownFunc, cleanupFunc, time.Duration(newInfrastructure.SConfig.Service.GracefulShutdownSecond)*time.Second)
}