From f579485745721f3bb6071ec56a41a7a4ae0c32da Mon Sep 17 00:00:00 2001 From: timerzz Date: Sun, 1 Sep 2024 19:13:56 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E4=BF=AE=E6=94=B9=E4=BC=98=E9=9B=85?= =?UTF-8?q?=E9=80=80=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/seller.go | 10 ++++++++-- go.mod | 3 ++- go.sum | 6 ++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/cmd/seller.go b/cmd/seller.go index d3316f5..fc1b8fe 100644 --- a/cmd/seller.go +++ b/cmd/seller.go @@ -1,7 +1,9 @@ package main import ( + "context" "os" + "os/signal" "gitea.timerzz.com/kedaya_haitao/common/pkg/database" "gitea.timerzz.com/kedaya_haitao/common/pkg/web" @@ -16,7 +18,8 @@ import ( func main() { glog.Info(">>> BEGIN INIT<<<") - + ctx, cancel := signal.NotifyContext(context.Background(), os.Kill, os.Interrupt) + defer cancel() // 初始化数据库 db, err := database.InitDefaultDatabase() if err != nil { @@ -44,7 +47,10 @@ func main() { if port == "" { port = "80" } - if err = r.Listen(":" + port); err != nil { + if err = r.Listen(":"+port, fiber.ListenConfig{ + EnablePrintRoutes: true, + GracefulContext: ctx, + }); err != nil { glog.Warningf("service over: %v", err) } } diff --git a/go.mod b/go.mod index 294ca61..321cfe0 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module gitea.timerzz.com/kedaya_haitao/seller go 1.22.5 require ( - gitea.timerzz.com/kedaya_haitao/common v0.0.0-20240827113521-2dfacfbe2cb2 + gitea.timerzz.com/kedaya_haitao/common v0.0.0-20240901105924-1290c1e1fd6a github.com/gofiber/fiber/v3 v3.0.0-beta.3 github.com/golang/glog v1.2.1 github.com/henrylee2cn/ameda v1.4.10 @@ -11,6 +11,7 @@ require ( require ( github.com/andybalholm/brotli v1.1.0 // indirect + github.com/expr-lang/expr v1.16.9 // indirect github.com/gofiber/utils/v2 v2.0.0-beta.4 // indirect github.com/google/uuid v1.6.0 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect diff --git a/go.sum b/go.sum index ceba83e..c534906 100644 --- a/go.sum +++ b/go.sum @@ -1,10 +1,12 @@ -gitea.timerzz.com/kedaya_haitao/common v0.0.0-20240827113521-2dfacfbe2cb2 h1:W+8KYg2w52P6XAVXdHt6/QirGytdJM2Bnyj50FMd084= -gitea.timerzz.com/kedaya_haitao/common v0.0.0-20240827113521-2dfacfbe2cb2/go.mod h1:VvR9l3uJFxfHCC+cKeVtNgEz35R7tWs/f2mGspaoUpU= +gitea.timerzz.com/kedaya_haitao/common v0.0.0-20240901105924-1290c1e1fd6a h1:BAsCJt5lj0L23qCzfy6dPhfDxoKrW64KxQtXTjuXfaA= +gitea.timerzz.com/kedaya_haitao/common v0.0.0-20240901105924-1290c1e1fd6a/go.mod h1:BIz+IMGznPiyLnV1+Ntw1zf8rEIcbymmGq+EfvDsSgE= github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/expr-lang/expr v1.16.9 h1:WUAzmR0JNI9JCiF0/ewwHB1gmcGw5wW7nWt8gc6PpCI= +github.com/expr-lang/expr v1.16.9/go.mod h1:8/vRC7+7HBzESEqt5kKpYXxrxkr31SaO8r40VO/1IT4= github.com/gofiber/fiber/v3 v3.0.0-beta.3 h1:7Q2I+HsIqnIEEDB+9oe7Gadpakh6ZLhXpTYz/L20vrg= github.com/gofiber/fiber/v3 v3.0.0-beta.3/go.mod h1:kcMur0Dxqk91R7p4vxEpJfDWZ9u5IfvrtQc8Bvv/JmY= github.com/gofiber/utils/v2 v2.0.0-beta.4 h1:1gjbVFFwVwUb9arPcqiB6iEjHBwo7cHsyS41NeIW3co=