main.go 1.0 KB

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