main.go 843 B

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