main.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package main
  2. import (
  3. "flag"
  4. "os"
  5. "os/signal"
  6. "syscall"
  7. "go-common/app/job/main/app-wall/conf"
  8. "go-common/app/job/main/app-wall/http"
  9. ecode "go-common/library/ecode/tip"
  10. "go-common/library/log"
  11. "go-common/library/net/trace"
  12. "go-common/library/queue/databus/report"
  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.Log)
  22. defer log.Close()
  23. log.Info("app-wall start")
  24. // init trace
  25. trace.Init(conf.Conf.Tracer)
  26. defer trace.Close()
  27. // ecode init
  28. ecode.Init(conf.Conf.Ecode)
  29. // report init
  30. report.InitUser(conf.Conf.Report)
  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-wall get a signal %s", s.String())
  40. switch s {
  41. case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
  42. http.Close()
  43. log.Info("app-wall exit")
  44. return
  45. case syscall.SIGHUP:
  46. default:
  47. return
  48. }
  49. }
  50. }