Browse Source

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

Jacky 1 day ago
parent
commit
06513abe4c
3 changed files with 6 additions and 5 deletions
  1. 1 1
      go.mod
  2. 2 4
      go.sum
  3. 3 0
      main.go

+ 1 - 1
go.mod

@@ -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

+ 2 - 4
go.sum

@@ -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=

+ 3 - 0
main.go

@@ -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)