main.go 749 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package main
  2. import (
  3. "os"
  4. "os/signal"
  5. "syscall"
  6. "go-common/app/service/ep/saga-agent/conf"
  7. "go-common/app/service/ep/saga-agent/service/agent"
  8. "go-common/library/log"
  9. )
  10. func listenSignal() {
  11. sigs := make(chan os.Signal, 1)
  12. signal.Notify(sigs, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGUSR1,
  13. syscall.SIGUSR2, syscall.SIGTSTP)
  14. select {
  15. case <-sigs:
  16. log.Info("get sig=%v\n, RunnerUnRegisterAll", sigs)
  17. agent.RunnerUnRegisterAll()
  18. default:
  19. log.Info("get sig=%v\n", sigs)
  20. }
  21. }
  22. func main() {
  23. log.Info("agent start......")
  24. err := conf.Init()
  25. if err != nil {
  26. panic(err)
  27. }
  28. go listenSignal()
  29. go agent.UpdateRegister()
  30. agent.ExecRegister()
  31. agent.RunnerStart()
  32. agent.RunnerUnRegisterAll()
  33. }