main.go 1002 B

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