diff --git a/cmd/main.go b/cmd/main.go index d1e4c8d..b923f2e 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -12,6 +12,8 @@ import ( dw_sdk "gitea.timerzz.com/kedaya_haitao/dw-sdk" "gitea.timerzz.com/kedaya_haitao/dw-spider/options" "gitea.timerzz.com/kedaya_haitao/dw-spider/spider" + "github.com/gofiber/fiber/v3" + "github.com/gofiber/fiber/v3/middleware/cors" "github.com/golang/glog" "gorm.io/gorm/logger" ) @@ -40,5 +42,15 @@ func main() { client := dw_sdk.NewClient(cfg.Dw) 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) + } }