boot.go 802 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package boot
  2. import (
  3. "github.com/gogf/gf/frame/g"
  4. "github.com/gogf/gf/net/ghttp"
  5. "github.com/gogf/gf/os/glog"
  6. )
  7. // 管理初始化顺序.
  8. func init() {
  9. initConfig()
  10. initRouter()
  11. }
  12. // 用于配置初始化.
  13. func initConfig() {
  14. glog.Info("########service start...")
  15. v := g.View()
  16. c := g.Config()
  17. s := g.Server()
  18. path := ""
  19. // 配置对象及视图对象配置
  20. c.AddPath(path + "config")
  21. v.SetDelimiters("${", "}")
  22. v.AddPath(path + "template")
  23. // glog配置
  24. logPath := c.GetString("log-path")
  25. glog.SetPath(logPath)
  26. glog.SetStdoutPrint(true)
  27. s.SetServerRoot("./public")
  28. s.SetNameToUriType(ghttp.NAME_TO_URI_TYPE_ALLLOWER)
  29. s.SetLogPath(logPath)
  30. s.SetErrorLogEnabled(true)
  31. s.SetAccessLogEnabled(true)
  32. s.SetPort(c.GetInt("http-port"))
  33. glog.Info("########service finish.")
  34. }