main.go 768 B

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