main.go 973 B

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