main.go 824 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package main
  2. import (
  3. "flag"
  4. "os"
  5. "os/signal"
  6. "syscall"
  7. "go-common/app/admin/main/bfs/conf"
  8. "go-common/app/admin/main/bfs/http"
  9. "go-common/app/admin/main/bfs/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. log.Info("bfs admin start")
  20. c := make(chan os.Signal, 1)
  21. srv := service.New(conf.Conf)
  22. http.Init(conf.Conf, srv)
  23. signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
  24. log.Info("bfs admin singal notify complete")
  25. for {
  26. s := <-c
  27. log.Info("bfs admin get a signal %s", s.String())
  28. switch s {
  29. case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
  30. srv.Close()
  31. log.Info("bfs admin exit")
  32. return
  33. case syscall.SIGHUP:
  34. default:
  35. return
  36. }
  37. }
  38. }