2018-08-14 09:25:34 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"strconv"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"git.trj.tw/golang/mtfosbot/model"
|
2018-09-10 10:13:27 +00:00
|
|
|
"git.trj.tw/golang/mtfosbot/module/background"
|
2018-08-22 09:20:12 +00:00
|
|
|
"git.trj.tw/golang/mtfosbot/module/config"
|
2018-09-13 10:18:59 +00:00
|
|
|
twitchirc "git.trj.tw/golang/mtfosbot/module/twitch-irc"
|
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
|
|
|
}
|
|
|
|
|
2018-09-10 10:13:27 +00:00
|
|
|
background.SetBackground()
|
|
|
|
|
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-09-15 15:48:40 +00:00
|
|
|
go twitchirc.InitIRC()
|
2018-09-13 10:18:59 +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
|
|
|
}
|