main.go 925 B

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