main.go 902 B

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