main.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package main
  2. import (
  3. "flag"
  4. "os"
  5. "os/signal"
  6. "syscall"
  7. "go-common/app/interface/main/app-feed/conf"
  8. "go-common/app/interface/main/app-feed/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. if err := conf.Init(); err != nil {
  16. log.Error("conf.Init() error(%v)", err)
  17. panic(err)
  18. }
  19. // init log
  20. log.Init(conf.Conf.XLog)
  21. defer log.Close()
  22. log.Info("app-feed start")
  23. // init trace
  24. trace.Init(conf.Conf.Tracer)
  25. defer trace.Close()
  26. // ecode init
  27. ecode.Init(conf.Conf.Ecode)
  28. // service init
  29. http.Init(conf.Conf)
  30. // init pprof conf.Conf.Perf
  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("app-feed get a signal %s", s.String())
  37. switch s {
  38. case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGSTOP, syscall.SIGINT:
  39. log.Info("app-feed exit")
  40. return
  41. case syscall.SIGHUP:
  42. // TODO reload
  43. default:
  44. return
  45. }
  46. }
  47. }