main.go 666 B

12345678910111213141516171819202122232425262728293031323334
  1. package main
  2. import (
  3. "fmt"
  4. cherryLogger "github.com/cherry-game/cherry/logger"
  5. "os"
  6. "os/signal"
  7. "syscall"
  8. "time"
  9. )
  10. func main() {
  11. fmt.Println("execute main...")
  12. sg := make(chan os.Signal)
  13. signal.Notify(sg, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGKILL, syscall.SIGTERM)
  14. select {
  15. case s := <-sg:
  16. cherryLogger.Infof("receive shutdown signal = %v.", s)
  17. shutdownComponent()
  18. }
  19. fmt.Println("exit main...")
  20. }
  21. func shutdownComponent() {
  22. fmt.Println("begin shutdownComponent ----------------------")
  23. for {
  24. time.Sleep(1 * time.Second)
  25. fmt.Println("test!" + time.Now().String())
  26. }
  27. fmt.Println("end shutdownComponent ----------------------")
  28. }