main.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package main
  2. import (
  3. "flag"
  4. "os"
  5. "os/signal"
  6. "syscall"
  7. "go-common/app/admin/main/member/conf"
  8. "go-common/app/admin/main/member/http"
  9. ecode "go-common/library/ecode/tip"
  10. "go-common/library/log"
  11. "go-common/library/net/trace"
  12. "go-common/library/queue/databus/report"
  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. // report log
  24. report.InitManager(conf.Conf.ManagerReport)
  25. log.Info("member start")
  26. // init trace
  27. trace.Init(conf.Conf.Tracer)
  28. defer trace.Close()
  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("member get a signal %s", s.String())
  40. switch s {
  41. case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
  42. log.Info("member exit")
  43. return
  44. case syscall.SIGHUP:
  45. default:
  46. return
  47. }
  48. }
  49. }