main.go 962 B

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