-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
50 lines (42 loc) · 1.16 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
package main
import (
"github.com/astaxie/beego"
"github.com/astaxie/beego/logs"
_ "github.com/go-sql-driver/mysql"
"github.com/initlove/ocihub/config"
"github.com/initlove/ocihub/logger"
"github.com/initlove/ocihub/models"
"github.com/initlove/ocihub/routers"
"github.com/initlove/ocihub/session"
_ "github.com/initlove/ocihub/session/memory"
"github.com/initlove/ocihub/storage"
_ "github.com/initlove/ocihub/storage/driver/filesystem"
)
func main() {
cfg, err := config.InitConfigFromFile("conf/ocihub.yml")
if err != nil {
return
}
if err := logger.InitLogger(cfg.Log); err != nil {
logs.Warning(err)
}
conn, _ := cfg.DB.GetConnection()
if err := models.InitDB(conn, cfg.DB.Driver, "default"); err != nil {
logs.Critical("Error in init db: ", err)
return
}
if err := storage.InitStorage(cfg.Storage); err != nil {
logs.Critical("Error in init storage: ", err)
return
}
if err := session.InitSession(cfg.Session); err != nil {
logs.Critical("Error in init session: ", err)
return
}
nss := router.GetNamespaces()
for name, ns := range nss {
logs.Debug("Namespace '%s' is enabled", name)
beego.AddNamespace(ns)
}
beego.Run()
}