-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
77 lines (61 loc) · 2.08 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package main
import (
"fmt"
gamePackage "github.com/BabichMikhail/Hanabi/game"
"github.com/BabichMikhail/Hanabi/middlewares"
"github.com/BabichMikhail/Hanabi/models"
_ "github.com/BabichMikhail/Hanabi/routers"
"github.com/Unknwon/goconfig"
"github.com/astaxie/beego"
"github.com/beego/compress"
"github.com/beego/wetalk/setting"
)
func SettingCompress() {
isProductMode := true
setting, err := compress.LoadJsonConf("conf/compress.json", isProductMode, "")
if err != nil {
beego.Error(err)
return
}
setting.RunCommand()
if isProductMode {
setting.RunCompress(true, false, true)
}
beego.AddFuncMap("compress_js", setting.Js.CompressJs)
beego.AddFuncMap("compress_css", setting.Css.CompressCss)
}
func decrease(value interface{}) int {
return value.(int) - 1
}
func init() {
beego.SetStaticPath("/images", "static/images")
beego.SetStaticPath("/css", "static/css")
beego.SetStaticPath("/js", "static/js")
beego.AddFuncMap("decrease", decrease)
gamePackage.RegisterFunction()
middlewares.InitMiddleware()
Cfg, err := goconfig.LoadConfigFile("conf/app.conf")
if err != nil {
panic(err)
}
Cfg.BlockMode = false
beego.BConfig.WebConfig.EnableXSRF = false
driverName := Cfg.MustValue("orm", "driver_name", "mysql")
dataSource := Cfg.MustValue("orm", "data_source", "root:root@/hanabi?charset=utf8")
maxIdle := Cfg.MustInt("orm", "max_idle_conn", 30)
maxOpen := Cfg.MustInt("orm", "max_open_conn", 50)
models.RegisterDatabase(driverName, dataSource, maxIdle, maxOpen)
setting.SecretKey = Cfg.MustValue("app", "secret_key")
if len(setting.SecretKey) == 0 {
fmt.Println("Please set your secret_key in app.conf file")
}
setting.LoginRememberDays = Cfg.MustInt("app", "login_remember_days", 7)
setting.LoginMaxRetries = Cfg.MustInt("app", "login_max_retries", 5)
setting.LoginFailedBlocks = Cfg.MustInt("app", "login_failed_blocks", 10)
setting.CookieRememberName = Cfg.MustValue("app", "cookie_remember_name", "hanabi_remember_name")
setting.CookieUserName = Cfg.MustValue("app", "cookie_user_name", "hanabi_cookie_name")
}
func main() {
SettingCompress()
beego.Run()
}