main.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package main
  2. import (
  3. "flag"
  4. "os"
  5. "os/signal"
  6. "syscall"
  7. "go-common/app/service/main/reply-feed/conf"
  8. "go-common/app/service/main/reply-feed/server/grpc"
  9. "go-common/app/service/main/reply-feed/server/http"
  10. "go-common/app/service/main/reply-feed/service"
  11. ecode "go-common/library/ecode/tip"
  12. "go-common/library/log"
  13. "go-common/library/net/trace"
  14. )
  15. func main() {
  16. flag.Parse()
  17. if err := conf.Init(); err != nil {
  18. panic(err)
  19. }
  20. log.Init(conf.Conf.Log)
  21. defer log.Close()
  22. log.Info("reply-feed service start")
  23. trace.Init(conf.Conf.Tracer)
  24. defer trace.Close()
  25. ecode.Init(conf.Conf.Ecode)
  26. svc := service.New(conf.Conf)
  27. http.Init(conf.Conf, svc)
  28. grpc.New(conf.Conf.GRPC, svc)
  29. c := make(chan os.Signal, 1)
  30. signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
  31. for {
  32. s := <-c
  33. log.Info("get a signal %s", s.String())
  34. switch s {
  35. case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
  36. svc.Close()
  37. log.Info("reply-feed service exit")
  38. return
  39. case syscall.SIGHUP:
  40. default:
  41. return
  42. }
  43. }
  44. }