mtgbot/main.go
2019-01-03 15:58:32 +08:00

50 lines
838 B
Go

package main
import (
"encoding/gob"
"fmt"
"log"
"git.trj.tw/golang/mtgbot/models"
"git.trj.tw/golang/mtgbot/modules/cmd"
"git.trj.tw/golang/mtgbot/modules/config"
"git.trj.tw/golang/mtgbot/modules/options"
"git.trj.tw/golang/mtgbot/router/routes"
)
func init() {
options.RegFlag()
}
func main() {
opts := options.GetOpts()
// Load config file
err := config.LoadConfig(opts.Config)
if err != nil {
log.Fatal(err)
}
conf := config.GetConf()
if opts.DBTool {
cmd.DBTool()
}
// init database connection
db := models.NewDB()
defer db.Close()
// register session object types
regTypes()
engine := routes.NewEngine()
routes.SetRoutes(engine)
engine.Run(fmt.Sprintf(":%d", conf.Port))
}
func regTypes() {
gob.Register(map[string]interface{}{})
gob.Register(models.Cards{})
gob.Register(models.Sets{})
}