mtfosbot/main.go

35 lines
579 B
Go
Raw Normal View History

2018-08-14 09:25:34 +00:00
package main
import (
"log"
"strconv"
"strings"
"git.trj.tw/golang/mtfosbot/model"
2018-08-22 09:20:12 +00:00
"git.trj.tw/golang/mtfosbot/module/config"
2018-08-14 09:25:34 +00:00
"git.trj.tw/golang/mtfosbot/router/routes"
"github.com/gin-gonic/gin"
)
var server *gin.Engine
func main() {
2018-08-22 09:20:12 +00:00
err := config.LoadConfig()
if err != nil {
log.Fatal(err)
2018-08-14 09:25:34 +00:00
}
// create http server
server = routes.NewServ()
routes.SetRoutes(server)
// connect to database
2018-08-28 03:55:38 +00:00
db, err := model.NewDB()
2018-08-14 09:25:34 +00:00
if err != nil {
log.Fatal(err)
}
2018-08-28 03:55:38 +00:00
defer db.Close()
2018-08-14 09:25:34 +00:00
2018-08-22 09:20:12 +00:00
server.Run(strings.Join([]string{":", strconv.Itoa(config.GetConf().Port)}, ""))
2018-08-14 09:25:34 +00:00
}