main.go 983 B

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