main.go 1.1 KB

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