main.go 965 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package main
  2. import (
  3. "flag"
  4. "os"
  5. "os/signal"
  6. "syscall"
  7. "go-common/app/admin/main/mcn/conf"
  8. "go-common/app/admin/main/mcn/server/http"
  9. ecode "go-common/library/ecode/tip"
  10. "go-common/library/log"
  11. "go-common/library/net/trace"
  12. manager "go-common/library/queue/databus/report"
  13. )
  14. func main() {
  15. flag.Parse()
  16. if err := conf.Init(); err != nil {
  17. panic(err)
  18. }
  19. log.Init(conf.Conf.Log)
  20. defer log.Close()
  21. log.SetFormat("[%D %T] [%L] [%S] %M")
  22. log.Info("start")
  23. trace.Init(conf.Conf.Tracer)
  24. defer trace.Close()
  25. // manager log init
  26. manager.InitManager(conf.Conf.ManagerLog)
  27. ecode.Init(conf.Conf.Ecode)
  28. http.Init(conf.Conf)
  29. c := make(chan os.Signal, 1)
  30. signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
  31. for {
  32. s := <-c
  33. log.Info("get a signal %s", s.String())
  34. switch s {
  35. case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
  36. log.Info("exit")
  37. return
  38. case syscall.SIGHUP:
  39. default:
  40. return
  41. }
  42. }
  43. }