This is my new blog CMS https://jlelse.blog
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

23 lines
330 B

package main
import (
"os"
"os/signal"
"sync"
"syscall"
)
var shutdownWg sync.WaitGroup
func onShutdown(f func()) {
defer shutdownWg.Done()
shutdownWg.Add(1)
quit := make(chan os.Signal, 1)
signal.Notify(quit, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
<-quit
f()
}
func waitForShutdown() {
shutdownWg.Wait()
}