main.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package main
  2. import (
  3. "crawler/config"
  4. "crawler/middleware"
  5. "crawler/route"
  6. "crawler/service"
  7. "crawler/utility"
  8. "github.com/gin-gonic/gin"
  9. "log"
  10. "net/http"
  11. "time"
  12. )
  13. /*
  14. @author 김국현
  15. @date 2022.12.25
  16. */
  17. func main() {
  18. utility.SetEnviron()
  19. utility.SetDebug()
  20. // MySQL DB 연결
  21. db := new(service.DB)
  22. service.DB_MOVIEW = db.Connection(config.DB_MOVIEW)
  23. service.DB_CRAWLER = db.Connection(config.DB_CRAWLER)
  24. service.DB_PLAYR = db.Connection(config.DB_PLAYR)
  25. app := gin.Default()
  26. app.Use(middleware.Access()) // 접속기록
  27. app.Use(middleware.GinBodyResponse()) // request 요청 로그
  28. // Routing
  29. route.SetRoute(app)
  30. var port = config.Env.APP.Port
  31. server := &http.Server{
  32. Addr: ":" + port,
  33. Handler: app,
  34. ReadTimeout: time.Duration(config.Env.APP.ReadTimeout) * time.Second,
  35. WriteTimeout: time.Duration(config.Env.APP.WriteTimeout) * time.Second,
  36. MaxHeaderBytes: config.Env.APP.MaxHeaderBytes << 20,
  37. }
  38. log.Println("Server was started successfully !!")
  39. log.Println(server.ListenAndServe())
  40. }