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

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)