main.go 913 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package main
  2. import (
  3. "flag"
  4. "os"
  5. "os/signal"
  6. "syscall"
  7. "go-common/app/interface/main/web-show/conf"
  8. "go-common/app/interface/main/web-show/http"
  9. "go-common/library/log"
  10. "go-common/library/net/trace"
  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.XLog)
  20. trace.Init(conf.Conf.Tracer)
  21. defer trace.Close()
  22. defer log.Close()
  23. log.Info("web-show start")
  24. // service init
  25. http.Init(conf.Conf)
  26. // init signal
  27. c := make(chan os.Signal, 1)
  28. signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
  29. for {
  30. s := <-c
  31. log.Info("web-show get a signal %s", s.String())
  32. switch s {
  33. case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
  34. http.CloseService()
  35. log.Info("web-show exit")
  36. return
  37. case syscall.SIGHUP:
  38. // TODO reload
  39. default:
  40. return
  41. }
  42. }
  43. }