main.go 876 B

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