main.go 1008 B

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