fix dead lock
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user