From a26ed821193cd2ea8cebc24c8e39dd711d484d85 Mon Sep 17 00:00:00 2001 From: timerzz Date: Mon, 29 Jul 2024 21:49:39 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E6=B7=BB=E5=8A=A0=E5=81=A5=E5=BA=B7?= =?UTF-8?q?=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/main.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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) + } }