main.go 1.0 KB

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