Files
honoka-chan/main.go
T
YumeMichi 150ce674ad Implement more endpoints & overhaul [2/n]
Drop LevelDB and move all the things to SQLite.

Implemented endpoints:
/api <unit, accessoryMaterialAll>
/api <unit, accessoryTab>
/live/continue
/live/partyList
/unit/favoriteAccessory (WIP)
/unit/sale

Signed-off-by: Sean Du <do4suki@gmail.com>
2026-04-28 11:44:56 +08:00

56 lines
1019 B
Go

package main
import (
"honoka-chan/config"
_ "honoka-chan/internal/handler"
"honoka-chan/internal/router"
"honoka-chan/internal/startup"
"honoka-chan/pkg/db"
"log"
"os"
"os/signal"
"syscall"
"github.com/gin-gonic/gin"
)
func main() {
// 初始化配置
config.InitConfig()
// 初始化数据库表和用户数据
startup.StartUp()
// 处理系统信号,确保程序退出时关闭数据库
signalChan := make(chan os.Signal, 1)
signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM)
go func() {
<-signalChan
log.Println("正在退出...")
db.MainEng.Close()
db.UserEng.Close()
os.Exit(0)
}()
// Gin
gin.SetMode(gin.ReleaseMode)
// Router
r := gin.New()
// Logger
r.Use(gin.LoggerWithConfig(gin.LoggerConfig{
SkipPaths: []string{
"/agreement/all",
"/integration/appReport/initialize",
"/report/ge/app",
},
}))
// SIF
router.SifRouter(r)
r.Run(":" + config.Conf.Settings.ListenPort) // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
}