main.go 982 B

123456789101112131415161718192021222324252627282930313233
  1. package main
  2. import (
  3. _ "ktogame/routers"
  4. _ "ktogame/util"
  5. "github.com/astaxie/beego"
  6. "github.com/astaxie/beego/logs"
  7. "github.com/astaxie/beego/plugins/cors"
  8. "github.com/beego/i18n"
  9. )
  10. func main() {
  11. log := logs.NewLogger()
  12. log.SetLogger(logs.AdapterConsole, `{"level":1,"color":false}`)
  13. logs.SetLogger(logs.AdapterFile, `{"filename":"listener.log","maxsize":512000,"maxlines":10000,"daily":true}`)
  14. logs.EnableFuncCallDepth(true)
  15. logs.SetLogFuncCallDepth(3)
  16. logs.Async()
  17. logs.Async(1e3)
  18. beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
  19. AllowAllOrigins: true,
  20. AllowMethods: []string{"*"},
  21. AllowHeaders: []string{"*"},
  22. ExposeHeaders: []string{"*"},
  23. AllowCredentials: true,
  24. AllowOrigins: []string{"http://172.*.*.*:*", "http://localhost:*", "http://127.0.0.1:*"},
  25. }))
  26. i18n.SetMessage("zh-CN", "conf/locale_zh-CN.ini")
  27. i18n.SetMessage("en-US", "conf/locale_en-US.ini")
  28. beego.BConfig.RecoverPanic = true
  29. beego.Run()
  30. }