main.go 755 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package main
  2. import (
  3. "flag"
  4. "os"
  5. "os/signal"
  6. "syscall"
  7. "go-common/app/job/main/thumbup/conf"
  8. "go-common/app/job/main/thumbup/server/http"
  9. "go-common/app/job/main/thumbup/service"
  10. "go-common/library/log"
  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. srv := service.New(conf.Conf)
  20. http.Init(conf.Conf, srv)
  21. ch := make(chan os.Signal, 1)
  22. signal.Notify(ch, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
  23. for {
  24. si := <-ch
  25. switch si {
  26. case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
  27. log.Info("get a signal %s, stop the consume process", si.String())
  28. srv.Close()
  29. return
  30. case syscall.SIGHUP:
  31. default:
  32. return
  33. }
  34. }
  35. }