feat(tfstated): add syscall.SIGTERM handling

This commit is contained in:
Julien Dessaux 2025-01-03 23:31:43 +01:00
parent c18d03d404
commit 63e2b1b09d
Signed by: adyxax
GPG key ID: F92E51B86E07177E

View file

@ -7,6 +7,7 @@ import (
"os" "os"
"os/signal" "os/signal"
"sync" "sync"
"syscall"
"time" "time"
"git.adyxax.org/adyxax/tfstated/pkg/backend" "git.adyxax.org/adyxax/tfstated/pkg/backend"
@ -19,7 +20,7 @@ func run(
db *database.DB, db *database.DB,
getenv func(string) string, getenv func(string) string,
) error { ) error {
ctx, cancel := signal.NotifyContext(ctx, os.Interrupt) ctx, cancel := signal.NotifyContext(ctx, os.Interrupt, syscall.SIGTERM)
defer cancel() defer cancel()
if err := db.InitAdminAccount(); err != nil { if err := db.InitAdminAccount(); err != nil {