main.go 1.1 KB

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