main.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package main
  2. import (
  3. "flag"
  4. "os"
  5. "os/signal"
  6. "syscall"
  7. "go-common/app/admin/main/reply/conf"
  8. "go-common/app/admin/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. // init conf,log,trace,stat,perf
  19. if err := conf.Init(); err != nil {
  20. panic(err)
  21. }
  22. log.Init(conf.Conf.Log)
  23. defer log.Close()
  24. trace.Init(conf.Conf.Tracer)
  25. defer trace.Close()
  26. ecode.Init(conf.Conf.Ecode)
  27. report.InitManager(conf.Conf.ManagerReport)
  28. // service init
  29. http.Init(conf.Conf)
  30. // perf init
  31. log.Info("reply-admin start")
  32. // signal handler
  33. c := make(chan os.Signal, 1)
  34. signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
  35. for {
  36. s := <-c
  37. log.Info("reply-admin get a signal %s", s.String())
  38. switch s {
  39. case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
  40. log.Info("reply-admin exit")
  41. return
  42. case syscall.SIGHUP:
  43. // TODO reload
  44. default:
  45. return
  46. }
  47. }
  48. }