main.go 990 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package main
  2. import (
  3. "flag"
  4. "os"
  5. "os/signal"
  6. "syscall"
  7. "go-common/app/admin/main/up-rating/conf"
  8. "go-common/app/admin/main/up-rating/http"
  9. "go-common/app/admin/main/up-rating/service"
  10. "go-common/library/log"
  11. "go-common/library/net/trace"
  12. )
  13. func main() {
  14. flag.Parse()
  15. // init conf,log,trace,stat,perf
  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. svr := service.New(conf.Conf)
  24. http.Init(conf.Conf, svr)
  25. log.SetFormat("[%D %T] [%L] [%S] %M")
  26. log.Info("up-rating-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("up-rating-admin get a signal %s", s.String())
  33. switch s {
  34. case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
  35. log.Info("up-rating-admin exit")
  36. return
  37. case syscall.SIGHUP:
  38. // TODO reload
  39. default:
  40. return
  41. }
  42. }
  43. }