main.go 975 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package main
  2. import (
  3. "flag"
  4. "os"
  5. "os/signal"
  6. "syscall"
  7. "go-common/app/interface/main/player/conf"
  8. "go-common/app/interface/main/player/http"
  9. ecode "go-common/library/ecode/tip"
  10. "go-common/library/log"
  11. "go-common/library/net/trace"
  12. )
  13. func main() {
  14. flag.Parse()
  15. if err := conf.Init(); err != nil {
  16. log.Error("conf.Init() error(%v)", err)
  17. panic(err)
  18. }
  19. log.Init(conf.Conf.XLog)
  20. defer log.Close()
  21. log.Info("play-interface start")
  22. trace.Init(conf.Conf.Tracer)
  23. defer trace.Close()
  24. // ecode
  25. ecode.Init(conf.Conf.Ecode)
  26. // service init
  27. http.Init(conf.Conf)
  28. // monitor
  29. // signal
  30. c := make(chan os.Signal, 1)
  31. signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
  32. for {
  33. s := <-c
  34. log.Info("play-interface get a signal %s", s.String())
  35. switch s {
  36. case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
  37. log.Info("play-interface exit")
  38. return
  39. case syscall.SIGHUP:
  40. // TODO reload
  41. default:
  42. return
  43. }
  44. }
  45. }