main.go 973 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package main
  2. import (
  3. "flag"
  4. "os"
  5. "os/signal"
  6. "syscall"
  7. "go-common/app/admin/openplatform/sug/conf"
  8. "go-common/app/admin/openplatform/sug/http"
  9. "go-common/app/admin/openplatform/sug/service"
  10. ecode "go-common/library/ecode/tip"
  11. "go-common/library/log"
  12. "go-common/library/net/trace"
  13. )
  14. func main() {
  15. flag.Parse()
  16. if err := conf.Init(); err != nil {
  17. log.Error("conf.Init() error(%v)", err)
  18. panic(err)
  19. }
  20. log.Init(conf.Conf.Log)
  21. defer log.Close()
  22. trace.Init(conf.Conf.Tracer)
  23. defer trace.Close()
  24. log.Info("sug-season start")
  25. ecode.Init(conf.Conf.Ecode)
  26. s := service.New(conf.Conf)
  27. http.Init(conf.Conf, s)
  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("open-sug get a signal %s", s.String())
  33. switch s {
  34. case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
  35. log.Info("open-sug exit")
  36. return
  37. case syscall.SIGHUP:
  38. default:
  39. return
  40. }
  41. }
  42. }