main.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package main
  2. import (
  3. "flag"
  4. _ "image/gif"
  5. _ "image/jpeg"
  6. _ "image/png"
  7. "os"
  8. "os/signal"
  9. "syscall"
  10. "time"
  11. "go-common/app/interface/main/upload/conf"
  12. "go-common/app/interface/main/upload/http"
  13. "go-common/app/interface/main/upload/service"
  14. ecode "go-common/library/ecode/tip"
  15. "go-common/library/log"
  16. "go-common/library/queue/databus/report"
  17. )
  18. func main() {
  19. flag.Parse()
  20. if err := conf.Init(); err != nil {
  21. log.Error("conf.Init() error(%v)", err)
  22. panic(err)
  23. }
  24. ecode.Init(conf.Conf.Ecode)
  25. // init log
  26. log.Init(conf.Conf.XLog)
  27. defer log.Close()
  28. // service init
  29. s := service.New(conf.Conf)
  30. http.Init(conf.Conf, s)
  31. report.InitUser(nil)
  32. log.Info("bfs-upload-interface start!")
  33. // init signal
  34. c := make(chan os.Signal, 1)
  35. signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
  36. for {
  37. s := <-c
  38. log.Info("upload get a signal %s", s.String())
  39. switch s {
  40. case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
  41. time.Sleep(1 * time.Second)
  42. log.Info("upload exit")
  43. return
  44. case syscall.SIGHUP:
  45. default:
  46. return
  47. }
  48. }
  49. }