-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
77 lines (63 loc) · 1.49 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package main
import (
"flag"
"log"
"os"
"path/filepath"
"sync"
"github.com/ESNFranceG33kTeam/CosmoAppy/database"
"github.com/ESNFranceG33kTeam/CosmoAppy/docs"
"github.com/ESNFranceG33kTeam/CosmoAppy/helpers"
"github.com/ESNFranceG33kTeam/CosmoAppy/logger"
"github.com/ESNFranceG33kTeam/CosmoAppy/modules/launcher"
"github.com/ESNFranceG33kTeam/CosmoAppy/router"
)
func startoptions() {
path, err := os.Getwd()
if err != nil {
log.Fatalln("Abs path doesn't exist !")
}
flag.StringVar(
&helpers.Confpathflag,
"conf",
filepath.Join(path, "conf/conf_local.yaml"),
"path for the configuration file.",
)
flag.StringVar(
&helpers.Swaggerpathflag,
"swagger",
"/conf/swagger.yaml",
"relative path for the swagger file.",
)
flag.Parse()
}
func InitConf() {
helpers.InitFile()
helpers.ReadConfig()
logger.GetLogger().LogInit()
}
func main() {
docs.DrawStart()
startoptions()
InitConf()
database.DatabaseInit()
router.InitializeRouter()
// Loading modules
launcher.LauncherModules()
logger.GetLogger().LogInfo("main", "Conf and modules loaded ; app starting...")
// Specimen data
if helpers.TheAppConfig().Specimen {
launcher.SpecimenModules()
}
logger.GetLogger().LogInfo("main", "API ready.")
// create a WaitGroup
wg := new(sync.WaitGroup)
// add two goroutines to `wg` WaitGroup
wg.Add(2)
go func() {
logger.GetLogger().LogCritical("main", "listen error", router.GetServer().ListenAndServe())
wg.Done()
}()
// wait until WaitGroup is done
wg.Wait()
}