-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathmain.go
executable file
·63 lines (48 loc) · 1.33 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
package main
import (
"fmt"
"github.com/astaxie/beego"
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/toolbox"
_ "github.com/go-sql-driver/mysql"
"kefu_server/controllers"
"kefu_server/db"
"kefu_server/grpcs"
_ "kefu_server/routers"
"kefu_server/task"
)
// Initialization log
func initLog() {
if isDev := beego.AppConfig.String("runmode"); isDev == "prod" {
_ = logs.SetLogger(logs.AdapterFile, `{"filename":"project.log","level":3,"maxlines":0,"maxsize":0,"daily":true,"maxdays":10,"color":true}`)
beego.SetLevel(beego.LevelError)
fmt.Print("当前环境为生产环境")
_ = beego.BeeLogger.DelLogger("console")
} else {
_ = logs.SetLogger(logs.AdapterConsole, `{"filename":"test.log","level":7,"maxlines":0,"maxsize":0,"daily":true,"maxdays":10,"color":true}`)
fmt.Print("当前环境为测试环境")
}
logs.EnableFuncCallDepth(true)
}
func main() {
end := make(chan bool, 1)
// init db
db.Run()
// init log
initLog()
// init task
task.Run()
toolbox.StartTask()
defer toolbox.StopTask()
/// Static file configuration
beego.SetStaticPath("/", "public/client")
beego.SetStaticPath("/admin", "public/admin")
beego.SetStaticPath("/static", "static")
// Handling Error
beego.ErrorController(&controllers.ErrorController{})
// grpcserver init
go grpcs.Run()
// run application
beego.Run()
<-end
}