fix(context): add context cancellation for graceful shutdown in Program function

This commit is contained in:
Jacky 2025-05-05 03:14:31 +00:00
parent 918ae3a6b6
commit 06513abe4c
No known key found for this signature in database
GPG key ID: 215C21B10DF38B4D
3 changed files with 6 additions and 5 deletions

2
go.mod
View file

@ -313,7 +313,7 @@ require (
)
replace (
code.pfad.fr/risefront => github.com/nginxui/risefront v1.1.7
code.pfad.fr/risefront => github.com/nginxui/risefront v1.1.8
github.com/tufanbarisyildirim/gonginx => github.com/0xJacky/gonginx v0.0.0-20250420001451-d120448e89a4
gorm.io/gorm => gorm.io/gorm v1.25.12
gorm.io/plugin/dbresolver => gorm.io/plugin/dbresolver v1.5.3

6
go.sum
View file

@ -1520,10 +1520,8 @@ github.com/nats-io/nkeys v0.2.0/go.mod h1:XdZpAbhgyyODYqjTawOnIOI7VlbKSarI9Gfy1t
github.com/nats-io/nkeys v0.3.0/go.mod h1:gvUNGjVcM2IPr5rCsRsC6Wb3Hr2CQAm08dsxtV6A5y4=
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms=
github.com/nginxui/risefront v1.1.6 h1:v6BhXuapeHowv0lhx4wa82Tct7zam4PLOS3ggXVtjdI=
github.com/nginxui/risefront v1.1.6/go.mod h1:QX3OyvazX3Mi/X2NZKl9ylDrFVUeaogwSMKyEsnRCHE=
github.com/nginxui/risefront v1.1.7 h1:Ffk00M80Q3fb9rXlwMfb3/XBspPLFMucLj6To89VK4E=
github.com/nginxui/risefront v1.1.7/go.mod h1:QX3OyvazX3Mi/X2NZKl9ylDrFVUeaogwSMKyEsnRCHE=
github.com/nginxui/risefront v1.1.8 h1:sriTY6/fYEi4m7s8nWV8L6tQ+4Sck7Fs8l8YzxQeReo=
github.com/nginxui/risefront v1.1.8/go.mod h1:QX3OyvazX3Mi/X2NZKl9ylDrFVUeaogwSMKyEsnRCHE=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nikoksr/notify v1.3.0 h1:UxzfxzAYGQD9a5JYLBTVx0lFMxeHCke3rPCkfWdPgLs=
github.com/nikoksr/notify v1.3.0/go.mod h1:Xor2hMmkvrCfkCKvXGbcrESez4brac2zQjhd6U2BbeM=

View file

@ -32,6 +32,9 @@ import (
func Program(ctx context.Context, confPath string) func(l []net.Listener) error {
return func(l []net.Listener) error {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
listener := l[0]
cosy.RegisterMigrationsBeforeAutoMigrate(migrate.BeforeAutoMigrate)