package main import ( "fmt" cherryLogger "github.com/cherry-game/cherry/logger" "os" "os/signal" "syscall" "time" ) func main() { fmt.Println("execute main...") sg := make(chan os.Signal) signal.Notify(sg, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGKILL, syscall.SIGTERM) select { case s := <-sg: cherryLogger.Infof("receive shutdown signal = %v.", s) shutdownComponent() } fmt.Println("exit main...") } func shutdownComponent() { fmt.Println("begin shutdownComponent ----------------------") for { time.Sleep(1 * time.Second) fmt.Println("test!" + time.Now().String()) } fmt.Println("end shutdownComponent ----------------------") }