diff --git a/cmd/provider.go b/cmd/provider.go index 03603b4..ac1c60f 100644 --- a/cmd/provider.go +++ b/cmd/provider.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" @@ -17,6 +19,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 +48,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 972a9cb..4fedd5b 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module gitea.timerzz.com/kedaya_haitao/provider 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=