Skip to content

Commit

Permalink
fix: run shutdown once
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe authored and moshloop committed Oct 15, 2024
1 parent 8d95a2e commit cc304fd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions shutdown/shutdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package shutdown
import (
"os"
"os/signal"
"sync"

"github.com/flanksource/commons/logger"
)

var shutdownHooks []func()

func Shutdown() {
var Shutdown = sync.OnceFunc(func() {
if len(shutdownHooks) == 0 {
return
}
Expand All @@ -18,7 +19,7 @@ func Shutdown() {
fn()
}
shutdownHooks = []func(){}
}
})

func ShutdownAndExit(code int, msg string) {
Shutdown()
Expand Down

0 comments on commit cc304fd

Please sign in to comment.