-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
57 lines (48 loc) · 1.22 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
package main
import (
"path/filepath"
_ "github.com/andycai/wejoin/administrator/components"
_ "github.com/andycai/wejoin/api/components"
"github.com/andycai/wejoin/api/middleware"
"github.com/andycai/wejoin/conf"
"github.com/andycai/wejoin/core"
"github.com/andycai/wejoin/library/authentication"
"github.com/andycai/wejoin/library/database"
"github.com/andycai/wejoin/log"
"gorm.io/gorm"
"github.com/gofiber/fiber/v2"
"github.com/spf13/viper"
)
func main() {
app := fiber.New()
log.Setup()
conf.ReadConf()
// database open and init
db, err := database.InitRDBMS(viper.GetString("db.type"),
viper.GetString("db.dsn"),
viper.GetInt("db.active"),
viper.GetInt("db.idle"),
viper.GetInt("db.idletimeout"))
if err != nil {
panic(err)
}
// dao.SetDefault(db)
dbs := []*gorm.DB{db}
core.AutoMigrate(dbs)
core.SetupDatabase(dbs)
authentication.SessionStart()
core.SetZoneOffset(viper.GetInt("app.zoneoffset"))
core.SetLang(viper.GetString("app.lang"))
// Middleware
middleware.Use(app)
app.Static("/static", filepath.Join("", viper.GetString("app.static")))
// router
core.SetupRouter(app)
err = app.Listen(viper.GetString("httpserver.addr"))
if err != nil {
panic(err)
}
defer func() {
//
}()
}