main.go 810 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package main
  2. import (
  3. "flag"
  4. "os"
  5. "os/signal"
  6. "syscall"
  7. "go-common/app/job/main/passport-user/conf"
  8. "go-common/app/job/main/passport-user/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.Xlog)
  18. defer log.Close()
  19. trace.Init(conf.Conf.Tracer)
  20. defer trace.Close()
  21. http.Init(conf.Conf)
  22. log.Info("passport-user-job start")
  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("passport-user-job get a signal %s", s.String())
  28. switch s {
  29. case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
  30. log.Info("passport-user-job exit")
  31. return
  32. case syscall.SIGHUP:
  33. default:
  34. return
  35. }
  36. }
  37. }