main.go 769 B

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