/
main.go
73 lines (58 loc) · 1.2 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
package main
import (
"fmt"
"mime"
"os"
"github.com/astaxie/beego"
"github.com/kevinxu001/houserent/models"
_ "github.com/kevinxu001/houserent/routers"
)
const (
VERSION = "0.1"
)
func main() {
// 初始化系统参数
beego.Info("Start init houserent system...")
initialize()
beego.Info("Init system successful")
beego.Info("Start houserent system server...")
beego.Run()
}
func initialize() {
mime.AddExtensionType(".css", "text/css")
// 判断命令行参数并执行初始化操作
initArgs()
//连接数据库
models.ConnectDB()
//初始化cache
models.InitCache()
//初始化session
models.InitSession()
//初始化logs
models.InitLogs()
//初始化i18n
models.InitI18n()
//初始化RBAC权限控制
models.InitAccessControl()
//beego.AddFuncMap("stringsToJson", StringsToJson)
}
var usage = `Survey is a on-line survey web application.
Usage:
survey [-syncdb | -h]
Description:
-syncdb Create database.This will delete all tables and data.
-h Show help page.
Use "bee -h" for this help.
`
func initArgs() {
args := os.Args
for _, v := range args {
if v == "-syncdb" {
models.SyncDB()
os.Exit(0)
} else if v == "-h" {
fmt.Println(usage)
os.Exit(0)
}
}
}