main.go 859 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package main
  2. import (
  3. "flag"
  4. "os"
  5. "os/signal"
  6. "syscall"
  7. "go-common/app/interface/main/mcn/conf"
  8. "go-common/app/interface/main/mcn/server/http"
  9. ecode "go-common/library/ecode/tip"
  10. "go-common/library/log"
  11. "go-common/library/net/trace"
  12. )
  13. func main() {
  14. flag.Parse()
  15. if err := conf.Init(); err != nil {
  16. panic(err)
  17. }
  18. log.Init(conf.Conf.Log)
  19. defer log.Close()
  20. log.SetFormat("[%D %T] [%L] [%S] %M")
  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. c := make(chan os.Signal, 1)
  27. signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
  28. for {
  29. s := <-c
  30. log.Info("get a signal %s", s.String())
  31. switch s {
  32. case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
  33. log.Info("exit")
  34. return
  35. case syscall.SIGHUP:
  36. default:
  37. return
  38. }
  39. }
  40. }