main.go 841 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package main
  2. import (
  3. "flag"
  4. "os"
  5. "os/signal"
  6. "syscall"
  7. "time"
  8. "go-common/app/interface/openplatform/monitor-end/conf"
  9. "go-common/app/interface/openplatform/monitor-end/http"
  10. "go-common/app/interface/openplatform/monitor-end/service"
  11. "go-common/library/log"
  12. "go-common/library/net/trace"
  13. )
  14. func main() {
  15. flag.Parse()
  16. conf.Init()
  17. log.Init(conf.Conf.Log)
  18. defer log.Close()
  19. trace.Init(nil)
  20. defer trace.Close()
  21. svr := service.New(conf.Conf)
  22. defer svr.Close()
  23. http.Init(conf.Conf, svr)
  24. c := make(chan os.Signal, 1)
  25. signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
  26. for {
  27. s := <-c
  28. switch s {
  29. case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGSTOP, syscall.SIGINT:
  30. time.Sleep(time.Second) // 休眠1s
  31. return
  32. case syscall.SIGHUP:
  33. // TODO reload
  34. default:
  35. return
  36. }
  37. }
  38. }