fix dead lock

This commit is contained in:
2026-02-08 23:49:23 +01:00
parent 156acf91dd
commit 3bfca34f3a
3 changed files with 41 additions and 11 deletions

View File

@@ -51,6 +51,7 @@ func run(ctx context.Context, debug bool) int {
if err := docker.StartWatcher(ctx, config.DaemonConfiguration.PullInterval); err != nil {
slog.Error("unable to start the docker watcher", "thread", "main", "err", err)
return failure
}
el, err := runtime.NewEventLoop(ctx, docker)
@@ -61,6 +62,7 @@ func run(ctx context.Context, debug bool) int {
defer el.Close()
go func() {
interruptNum := 0
c := make(chan os.Signal, 10)
signal.Notify(c)
defer close(c)
@@ -69,16 +71,21 @@ func run(ctx context.Context, debug bool) int {
switch sig {
case os.Interrupt:
{
interruptNum++
slog.Info("the process received an interruption signal", "thread", "signal_watcher", "signal", sig.String())
el.Close()
}
case os.Kill:
{
interruptNum++
slog.Info("the process received a kill signal", "thread", "signal_watcher", "signal", sig.String())
el.Close()
}
}
if interruptNum == 3 {
slog.Info("received 3 times a stop signal, forcing the program to shut down", "thread", "signal_watch")
os.Exit(failure)
}
}
}()