main.go 990 B

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