main.go 886 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package main
  2. import (
  3. "flag"
  4. "os"
  5. "os/signal"
  6. "syscall"
  7. "go-common/app/job/main/passport-user-compare/conf"
  8. "go-common/app/job/main/passport-user-compare/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. log.Error("conf.Init() error(%v)", err)
  16. panic(err)
  17. }
  18. log.Init(conf.Conf.Log)
  19. defer log.Close()
  20. // init trace
  21. trace.Init(conf.Conf.Tracer)
  22. defer trace.Close()
  23. // service init
  24. http.Init(conf.Conf)
  25. // init signal
  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("passport-user-compare get a signal %s", s.String())
  31. switch s {
  32. case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
  33. log.Info("passport-user-compare exit")
  34. return
  35. case syscall.SIGHUP:
  36. default:
  37. return
  38. }
  39. }
  40. }