main.go 862 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package main
  2. import (
  3. "flag"
  4. "os"
  5. "os/signal"
  6. "syscall"
  7. "go-common/app/service/main/msm/conf"
  8. "go-common/app/service/main/msm/http"
  9. "go-common/app/service/main/msm/service"
  10. "go-common/library/log"
  11. )
  12. func main() {
  13. flag.Parse()
  14. if err := conf.Init(); err != nil {
  15. log.Error("conf.Init() error(%v)", err)
  16. panic(err)
  17. }
  18. // init log
  19. log.Init(conf.Conf.Log)
  20. defer log.Close()
  21. log.Info("msm-service start")
  22. svr := service.New(conf.Conf)
  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. log.Info("msm-service get a signal %s", s.String())
  29. switch s {
  30. case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
  31. svr.Close()
  32. log.Info("msm-service exit")
  33. return
  34. case syscall.SIGHUP:
  35. // TODO reload
  36. default:
  37. return
  38. }
  39. }
  40. }