main.go 963 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package main
  2. import (
  3. "flag"
  4. "os"
  5. "os/signal"
  6. "syscall"
  7. "go-common/app/service/bbq/recsys/conf"
  8. "go-common/app/service/bbq/recsys/server/grpc"
  9. "go-common/app/service/bbq/recsys/server/http"
  10. "go-common/app/service/bbq/recsys/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("start")
  23. trace.Init(conf.Conf.Tracer)
  24. defer trace.Close()
  25. ecode.Init(conf.Conf.Ecode)
  26. srv := service.New(conf.Conf)
  27. grpc.New(srv)
  28. http.Init(conf.Conf, srv)
  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. log.Info("exit")
  37. return
  38. case syscall.SIGHUP:
  39. default:
  40. return
  41. }
  42. }
  43. }