main.go 745 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package main
  2. import (
  3. "flag"
  4. "os"
  5. "os/signal"
  6. "syscall"
  7. "go-common/app/admin/main/cache/conf"
  8. "go-common/app/admin/main/cache/http"
  9. ecode "go-common/library/ecode/tip"
  10. "go-common/library/log"
  11. )
  12. func main() {
  13. flag.Parse()
  14. if err := conf.Init(); err != nil {
  15. panic(err)
  16. }
  17. log.Init(conf.Conf.Log)
  18. defer log.Close()
  19. log.Info("cache start")
  20. ecode.Init(conf.Conf.Ecode)
  21. http.Init(conf.Conf)
  22. c := make(chan os.Signal, 1)
  23. signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
  24. for {
  25. s := <-c
  26. log.Info("cache get a signal %s", s.String())
  27. switch s {
  28. case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
  29. log.Info("cache exit")
  30. return
  31. case syscall.SIGHUP:
  32. default:
  33. return
  34. }
  35. }
  36. }