main.go 873 B

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