feat 修改优雅退出
All checks were successful
Build image / build (push) Successful in 1m0s

This commit is contained in:
timerzz 2024-09-01 19:13:55 +08:00
parent 9f24da3d19
commit 6c9da2c382
3 changed files with 14 additions and 4 deletions

View File

@ -1,7 +1,9 @@
package main package main
import ( import (
"context"
"os" "os"
"os/signal"
"gitea.timerzz.com/kedaya_haitao/common/pkg/database" "gitea.timerzz.com/kedaya_haitao/common/pkg/database"
"gitea.timerzz.com/kedaya_haitao/common/pkg/web" "gitea.timerzz.com/kedaya_haitao/common/pkg/web"
@ -17,6 +19,8 @@ import (
func main() { func main() {
glog.Info(">>> BEGIN INIT<<<") glog.Info(">>> BEGIN INIT<<<")
ctx, cancel := signal.NotifyContext(context.Background(), os.Kill, os.Interrupt)
defer cancel()
// 初始化数据库 // 初始化数据库
db, err := database.InitDefaultDatabase() db, err := database.InitDefaultDatabase()
if err != nil { if err != nil {
@ -44,7 +48,10 @@ func main() {
if port == "" { if port == "" {
port = "80" 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) glog.Warningf("service over: %v", err)
} }
} }

3
go.mod
View File

@ -3,7 +3,7 @@ module gitea.timerzz.com/kedaya_haitao/provider
go 1.22.5 go 1.22.5
require ( 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/gofiber/fiber/v3 v3.0.0-beta.3
github.com/golang/glog v1.2.1 github.com/golang/glog v1.2.1
github.com/henrylee2cn/ameda v1.4.10 github.com/henrylee2cn/ameda v1.4.10
@ -11,6 +11,7 @@ require (
require ( require (
github.com/andybalholm/brotli v1.1.0 // indirect 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/gofiber/utils/v2 v2.0.0-beta.4 // indirect
github.com/google/uuid v1.6.0 // indirect github.com/google/uuid v1.6.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect

6
go.sum
View File

@ -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-20240901105924-1290c1e1fd6a h1:BAsCJt5lj0L23qCzfy6dPhfDxoKrW64KxQtXTjuXfaA=
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/go.mod h1:BIz+IMGznPiyLnV1+Ntw1zf8rEIcbymmGq+EfvDsSgE=
github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M=
github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY= 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.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 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 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 h1:7Q2I+HsIqnIEEDB+9oe7Gadpakh6ZLhXpTYz/L20vrg=
github.com/gofiber/fiber/v3 v3.0.0-beta.3/go.mod h1:kcMur0Dxqk91R7p4vxEpJfDWZ9u5IfvrtQc8Bvv/JmY= 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= github.com/gofiber/utils/v2 v2.0.0-beta.4 h1:1gjbVFFwVwUb9arPcqiB6iEjHBwo7cHsyS41NeIW3co=