main.go 921 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package main
  2. import (
  3. "flag"
  4. "os"
  5. "os/signal"
  6. "syscall"
  7. "go-common/app/interface/main/tv/conf"
  8. "go-common/app/interface/main/tv/http"
  9. ecode "go-common/library/ecode/tip"
  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. ecode.Init(conf.Conf.Ecode)
  24. http.Init(conf.Conf)
  25. // signal handler
  26. log.Info("tv-interface start")
  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("tv-interface get a signal %s", s.String())
  32. switch s {
  33. case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
  34. log.Info("tv-interface exit")
  35. return
  36. case syscall.SIGHUP:
  37. // TODO reload
  38. default:
  39. return
  40. }
  41. }
  42. }