main.go 798 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package main
  2. import (
  3. "flag"
  4. "os"
  5. "os/signal"
  6. "syscall"
  7. "go-common/app/service/main/riot-search/conf"
  8. "go-common/app/service/main/riot-search/server/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. panic(err)
  16. }
  17. log.Init(conf.Conf.Log)
  18. defer log.Close()
  19. log.Info("start")
  20. trace.Init(conf.Conf.Tracer)
  21. defer trace.Close()
  22. // ecode.Init(conf.Conf.Ecode)
  23. http.Init(conf.Conf)
  24. c := make(chan os.Signal, 1)
  25. signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
  26. for {
  27. s := <-c
  28. log.Info("get a signal %s", s.String())
  29. switch s {
  30. case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
  31. log.Info("exit")
  32. return
  33. case syscall.SIGHUP:
  34. default:
  35. return
  36. }
  37. }
  38. }