feat 添加健康检查
Some checks failed
Build image / build (push) Failing after 3m29s

This commit is contained in:
timerzz 2024-07-29 21:49:39 +08:00
parent 70e1f4c6bc
commit a26ed82119

View File

@ -12,6 +12,8 @@ import (
dw_sdk "gitea.timerzz.com/kedaya_haitao/dw-sdk" dw_sdk "gitea.timerzz.com/kedaya_haitao/dw-sdk"
"gitea.timerzz.com/kedaya_haitao/dw-spider/options" "gitea.timerzz.com/kedaya_haitao/dw-spider/options"
"gitea.timerzz.com/kedaya_haitao/dw-spider/spider" "gitea.timerzz.com/kedaya_haitao/dw-spider/spider"
"github.com/gofiber/fiber/v3"
"github.com/gofiber/fiber/v3/middleware/cors"
"github.com/golang/glog" "github.com/golang/glog"
"gorm.io/gorm/logger" "gorm.io/gorm/logger"
) )
@ -40,5 +42,15 @@ func main() {
client := dw_sdk.NewClient(cfg.Dw) client := dw_sdk.NewClient(cfg.Dw)
ctl := spider.NewController(client, db) ctl := spider.NewController(client, db)
ctl.Run(ctx) go ctl.Run(ctx)
r := fiber.New()
r.Use(cors.New())
r.Get("/health", func(ctx fiber.Ctx) error {
return ctx.SendString("ok")
})
if err = r.Listen(":8080"); err != nil {
glog.Warningf("server over: %v", err)
}
} }