main.go 1.0 KB

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