-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathmain.go
54 lines (42 loc) · 1.02 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
package main
import (
"flag"
"fmt"
"github.com/astaxie/beego"
"github.com/kenshinx/joke/controllers"
)
/*
Joke: The web console of godns
*/
const (
Author = "kenshin"
Version = "0.1.1"
)
func main() {
initConfig()
initLogger()
beego.Router("/", &controllers.IndexController{})
beego.Router("/dns", &controllers.DNSController{})
beego.Router("/dns/del", &controllers.DNSDelController{})
beego.Run()
}
func initConfig() {
var configFile string
flag.StringVar(&configFile, "c", "./conf/app.conf", "Path to the application configuration file")
flag.Parse()
if err := beego.LoadAppConfig("ini", configFile); err != nil {
panic(err)
}
}
func initLogger() {
console, _ := beego.AppConfig.Bool("stdout")
if !console {
beego.BeeLogger.DelLogger("console")
}
if beego.AppConfig.String("logfile") != "" {
cfg := fmt.Sprintf(`{"filename":"%s"}`, beego.AppConfig.String("logfile"))
beego.BeeLogger.SetLogger("file", cfg)
}
beego.BeeLogger.SetLevel(beego.LevelDebug)
beego.BeeLogger.EnableFuncCallDepth(false)
}