main.go 884 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package main
  2. import (
  3. "flag"
  4. "os"
  5. "os/signal"
  6. "syscall"
  7. "go-common/app/service/ep/footman/conf"
  8. "go-common/app/service/ep/footman/server/http"
  9. "go-common/app/service/ep/footman/service"
  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. defer trace.Close()
  23. ecode.Init(conf.Conf.Ecode)
  24. s := service.New(conf.Conf)
  25. http.Init(conf.Conf, s)
  26. c := make(chan os.Signal, 1)
  27. signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
  28. for {
  29. si := <-c
  30. log.Info("get a signal %s", si.String())
  31. switch si {
  32. case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
  33. log.Info("exit")
  34. s.Close()
  35. return
  36. case syscall.SIGHUP:
  37. default:
  38. return
  39. }
  40. }
  41. }