func init() {
	_, file, _, _ := runtime.Caller(1)
	apppath, _ := filepath.Abs(filepath.Dir(filepath.Join(file,
		".."+string(filepath.Separator))))
	beego.TestBeegoInit(apppath)
	beego.SetLevel(logs.LevelInfo)
}
Exemple #2
0
func main() {
	models.Init()
	jobs.InitJobs()

	// 设置默认404页面
	beego.Errorhandler("404", func(rw http.ResponseWriter, r *http.Request) {
		t, _ := template.New("404.html").ParseFiles(beego.ViewsPath + "/error/404.html")
		data := make(map[string]interface{})
		data["content"] = "page not found"
		t.Execute(rw, data)
	})

	// 生产环境不输出debug日志
	if beego.AppConfig.String("runmode") == "prod" {
		beego.SetLevel(beego.LevelInformational)
	}
	beego.AppConfig.Set("version", VERSION)

	// 路由设置
	beego.Router("/", &controllers.MainController{}, "*:Index")
	beego.Router("/login", &controllers.MainController{}, "*:Login")
	beego.Router("/logout", &controllers.MainController{}, "*:Logout")
	beego.Router("/profile", &controllers.MainController{}, "*:Profile")
	beego.Router("/gettime", &controllers.MainController{}, "*:GetTime")
	beego.Router("/help", &controllers.HelpController{}, "*:Index")
	beego.AutoRouter(&controllers.TaskController{})
	beego.AutoRouter(&controllers.GroupController{})

	beego.SessionOn = true
	beego.Run()
}
Exemple #3
0
func init() {
	// Try to have highest performance.
	runtime.GOMAXPROCS(runtime.NumCPU())

	// Set application log level.
	beego.SetLevel(beego.LevelTrace)

	// Initialize log file.
	os.Mkdir("./log", os.ModePerm)
	// Compute log file name as format '<year>-<month>-<day>.txt', eg.'2013-5-6.txt'.
	logName := fmt.Sprintf("./log/%d-%d-%d.txt", time.Now().Year(), time.Now().Month(), time.Now().Day())
	// Open or create log file.
	var fl *os.File
	var err error
	if utils.IsExist(logName) {
		fl, err = os.OpenFile(logName, os.O_RDWR|os.O_APPEND, 0644)
	} else {
		fl, err = os.Create(logName)
	}
	if err != nil {
		beego.Trace("Failed to init log file ->", err)
		return
	}
	beego.Info("Go Walker", VERSION)
	beego.SetLogger(log.New(fl, "", log.Ldate|log.Ltime))
}
Exemple #4
0
Fichier : main.go Projet : lcbyz/Go
func main() {
	beego.SetLevel(beego.LevelInformational)
	beego.SetLogFuncCall(true)
	beego.SetLogger("file", `{"filename":"logs/test.log"}`)
	orm.Debug = true
	orm.RunSyncdb("default", false, true)
	beego.Run()
}
Exemple #5
0
func main() {
	//	beego.SetLogger("file", `{"filename":"logs/test.log"}`)
	mode := beego.AppConfig.String("runmode")
	if mode == "prod" {
		beego.SetLevel(beego.LevelInformational)
	}
	//	go demo()
	beego.Run()
}
Exemple #6
0
// We have to call a initialize function manully
// because we use `bee bale` to pack static resources
// and we cannot make sure that which init() execute first.
func initialize() {
	models.InitModels()

	routers.IsPro = beego.RunMode == "prod"
	if routers.IsPro {
		beego.SetLevel(beego.LevelInfo)
		os.Mkdir("./log", os.ModePerm)
		beego.BeeLogger.SetLogger("file", `{"filename": "log/log"}`)
	}

	routers.InitApp()
}
Exemple #7
0
func (c *MainController) Get() {
	// c.Data["Website"] = "beego.me"
	// c.Data["Email"] = "*****@*****.**"
	// c.TplName = "index.tpl"
	c.Ctx.WriteString("appname: " + beego.AppConfig.String("appname") +
		"\nhttpport: " + beego.AppConfig.String("httpport") +
		"\nrunmode: " + beego.AppConfig.String("runmode"))

	beego.Trace("trace 1")
	beego.Info("info 1")
	beego.SetLevel(beego.LevelInformational)
	beego.Trace("trace 2")
	beego.Info("info 2")
}
Exemple #8
0
func main() {
	beego.SessionOn = true
	beego.ErrorController(&controllers.ErrorController{})
	beego.AddFuncMap("i18n", i18n.Tr)

	beego.EnableAdmin = true // Port 8088

	beego.SetLogger("file", `{"filename":"logs/juna.log"}`)
	beego.SetLevel(beego.LevelInformational)
	beego.SetLogFuncCall(true)

	beego.AddFuncMap("news", news)
	beego.Run()
}
Exemple #9
0
func main() {

	models.InitDb()
	beego.SessionOn = true
	beego.SetLogger("file", `{"filename":"`+common.Webconfig.LogFile+`"}`)
	beego.SetLevel(beego.LevelInformational)
	beego.SetLogFuncCall(true)
	beego.Info("begin setting router")

	beego.Router("/", &routers.HomeRouter{})
	beego.Router(`/page/:page([\d]+)`, &routers.HomeRouter{})

	beego.Router(`/article/:article([\w-]+)`, &routers.ArticleRouter{})

	beego.Router(`/tag/:tag([\S]+)/:page([\d]+)`, &routers.TagRouter{})
	beego.Router(`/tag/:tag([\S]+)`, &routers.TagRouter{})

	beego.Router(`/node/:node([\S]+)/:page([\d]+)`, &routers.NodeRouter{})
	beego.Router(`/node/:node([\S]+)`, &routers.NodeRouter{})

	beego.Router(`/category/:category([\S]+)/:page([\d]+)`, &routers.CategoryRouter{})
	beego.Router(`/category/:category([\S]+)`, &routers.CategoryRouter{})

	beego.Router("/subscribe", &routers.SubscribeRouter{})
	beego.Router(`/subscribe/:uid([\S]+)`, &routers.SubscribeRouter{})
	beego.Router(`/desubscribe/:uid([\S]+)`, &routers.SubscribeRouter{})

	beego.Router("/root", &root.RootMainRouter{})

	beego.Router("/root/category", &root.RootCategoryRouter{})

	beego.Router("/root/node", &root.RootNodeRouter{})

	beego.Router("/root/tag", &root.RootTagRouter{})

	beego.Router(`/root/article`, &root.RootArticleRouter{})
	//beego.Router(`/root/article/:opt([a-z]+)`, &root.RootArticleRouter{})
	beego.Router(`/root/article/:page([\d]+)`, &root.RootArticleRouter{})

	beego.Router("/root/upload", &root.RootUploadRouter{})

	beego.Router("/root/login", &root.LoginRouter{})
	beego.Router("/root/loginout", &root.LoginOutRouter{})

	beego.Router(`/prompt/:code([\w]+)`, &routers.PromptRouter{})

	beego.Info("starting server")
	beego.Run()
}
Exemple #10
0
// We have to call a initialize function manully
// because we use `bee bale` to pack static resources
// and we cannot make sure that which init() execute first.
func initialize() {
	models.InitModels()
	routers.InitRouter()

	// Set App version and log level.
	beego.AppName = models.Cfg.MustValue("beego", "app_name")
	beego.HttpPort = models.Cfg.MustInt("beego", "http_port_"+beego.RunMode)

	routers.IsPro = beego.RunMode == "pro"
	if routers.IsPro {
		beego.SetLevel(beego.LevelInfo)
		os.Mkdir("./log", os.ModePerm)
		beego.BeeLogger.SetLogger("file", `{"filename": "log/log"}`)
	}
}
Exemple #11
0
// We have to call a initialize function manully
// because we use `bee bale` to pack static resources
// and we cannot make sure that which init() execute first.
func initialize() {
	setting.LoadConfig()

	//set logger
	if setting.IsProMode {
		beego.SetLogger("file", `{"filename":"logs/prod.log"}`)
		beego.SetLevel(beego.LevelInformational)
		beego.BeeLogger.DelLogger("console")
	} else {
		beego.SetLogger("file", `{"filename":"logs/dev.log"}`)
		beego.SetLevel(beego.LevelDebug)
		beego.BeeLogger.SetLogger("console", "")
	}
	beego.SetLogFuncCall(true)
	setting.SocialAuth = social.NewSocial("/login/", auth.SocialAuther)
	setting.SocialAuth.ConnectSuccessURL = "/settings/profile"
	setting.SocialAuth.ConnectFailedURL = "/settings/profile"
	setting.SocialAuth.ConnectRegisterURL = "/register/connect"
	setting.SocialAuth.LoginURL = "/login"

	//Qiniu
	ACCESS_KEY = setting.QiniuAccessKey
	SECRET_KEY = setting.QiniuSecurityKey
}
Exemple #12
0
func init() {
	GlobalSessions, _ = session.NewManager("memory", `{
												"cookieName":"lte_securityid",
												"enableSetCookie,omitempty": true,
												"gclifetime":3600,
												"maxLifetime": 3600,
												"secure": true,
												"sessionIDHashFunc": "sha1",
												"sessionIDHashKey": "",
												"cookieLifeTime": 3600,
												"providerConfig": ""}`)
	go GlobalSessions.GC()
	beego.SetLogger("file", `{"filename":"logs/server.log"}`)
	beego.SetLevel(beego.LevelDebug)
}
Exemple #13
0
func init() {
	//ceshi
	//设置log格式
	beego.SetLogger("file", `{"filename":"logs/server.log"}`)
	beego.SetLevel(beego.LevelDebug)

	//设置session
	/*kkk
	beego.SessionOn = true
	beego.SessionProvider = "redis"
	beego.SessionSavePath = "192.168.15.43:6379"
	beego.SessionName = "LMSsessionID"
	beego.SessionGCMaxLifetime = 60
	beego.SessionCookieLifeTime = 60
	*/
}
Exemple #14
0
func init() {
	beego.AppConfigPath = "conf/app.conf"
	beego.SetStaticPath("/js", "public/js")
	beego.SetStaticPath("/img", "public/img")
	beego.SetStaticPath("/favicon.ico", "public/img/favicon.ico")
	beego.SetStaticPath("/css", "public/css")
	beego.SetStaticPath("/html", "tpl")
	beego.SetStaticPath("/admin/js", "public/admin/js")
	beego.SetStaticPath("/admin/img", "public/admin/img")
	beego.SetStaticPath("/admin/css", "public/admin/css")
	beego.SetStaticPath("/admin/assets", "public/admin")
	beego.SetLevel(beego.LevelDebug)
	beego.SetLogFuncCall(true)
	beego.BeeLogger.SetLogFuncCallDepth(4)
	bm, _ = cache.NewCache("memory", `{"interval":60}`)
}
Exemple #15
0
func init() {
	//runtime.GOMAXPROCS(runtime.NumCPU())

	// Set App version and log level.
	routers.IsPro = beego.AppConfig.String("runmode") == "pro"
	if routers.IsPro {
		beego.SetLevel(beego.LevelInfo)

		beego.Info("Beego Web", APP_VER)

		os.Mkdir("./log", os.ModePerm)
		beego.BeeLogger.SetLogger("file", "log/log")
	} else {
		// beewatch.Start(beewatch.Trace)
	}
}
Exemple #16
0
func initialize() {

	models.InitModels()

	// Set App version and log level.
	beego.AppName = models.Cfg.MustValue("beego", "app_name")
	beego.RunMode = models.Cfg.MustValue("beego", "run_mode")

	controllers.IsPro = beego.RunMode == "prod"
	if controllers.IsPro {
		beego.SetLevel(beego.LevelInfo)
		os.Mkdir("./log", os.ModePerm)
		beego.BeeLogger.SetLogger("file", `{"filename": "log/log"}`)
	}
	controllers.InitApp()
}
Exemple #17
0
func init() {
	runtime.GOMAXPROCS(runtime.NumCPU())

	// Set App version and log level.
	if beego.AppConfig.String("runmode") == "pro" {
		beego.SetLevel(beego.LevelInfo)

		beego.Info("Beego Web", APP_VER)

		os.Mkdir("./log", os.ModePerm)
		filew := beego.NewFileWriter("log/log", true)
		err := filew.StartLogger()
		if err != nil {
			beego.Critical("NewFileWriter ->", err)
		}
	}
}
Exemple #18
0
func (c *MainController) Get() {
	c.Ctx.WriteString("appname: " + beego.AppConfig.String("appname") +
		"\nhttpport: " + beego.AppConfig.String("httpport") +
		"\nrunmode: " + beego.AppConfig.String("runmode"))

	c.Ctx.WriteString("\n\nappname: " + beego.AppName +
		"\nhttpport: " + strconv.Itoa(beego.HttpPort) +
		"\nrunmode: " + beego.RunMode)

	beego.Trace("trace test1..")
	beego.Info("test1...")

	beego.SetLevel(beego.LevelInformational)

	beego.Trace("trace test2..")
	beego.Info("test2...")
}
Exemple #19
0
func init() {
	//设置log格式
	beego.SetLogger("file", `{"filename":"logs/server.log"}`)
	beego.SetLevel(beego.LevelDebug)

	//设置下载脚本目录
	beego.SetStaticPath("/script_download", "script_download")

	//设置session
	/*
		beego.SessionOn = true
		beego.SessionProvider = "redis"
		beego.SessionSavePath = "192.168.15.43:6379"
		beego.SessionName = "LMSsessionID"
		beego.SessionGCMaxLifetime = 60
		beego.SessionCookieLifeTime = 60
	*/
}
func (this *MainController) Get() {
	// 配置管理
	this.Ctx.WriteString("AppName: " + beego.AppConfig.String("appname") +
		"\nRunMode: " + beego.AppConfig.String("runmode"))

	// 默认参数
	this.Ctx.WriteString("\n\nAppName: " + beego.AppName +
		"\nRunMode: " + beego.RunMode)

	// 日志级别
	beego.Trace("Trace test1")
	beego.Info("Info test1")

	beego.SetLevel(beego.LevelInfo)

	beego.Trace("Trace test2")
	beego.Info("Info test2")
}
Exemple #21
0
/*
启动服务
name:显示名称
service:service为true,desktop为false
*/
func doWork(name string, service bool) {
	//桌面服务日志
	beego.BeeLogger.SetLogger("file", `{"filename":"`+utils.Sqlite3Path(beego.AppConfig.String("LogPath"))+`"}`)
	beego.SetLevel(beego.LevelWarning)
	//日志
	beego.Error(name + ` 服务启动`)

	//模板函数
	templateFunc()
	//路由
	router()
	//主要是初始化 i18n 文件
	utils.I18n()
	//初始化数据库注册
	models.Init()

	beego.Run()

}
Exemple #22
0
func main() {
	//setUserId()

	graceful, _ := beego.AppConfig.Bool("graceful")
	if !graceful {
		sigs := make(chan os.Signal, 1)
		signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM,
			syscall.SIGQUIT)
		go handleSignals(sigs)
	}

	beego.SetLogger("file", `{"filename":"logs/test.log"}`)
	mode := beego.AppConfig.String("runmode")
	if mode == "prod" {
		beego.SetLevel(beego.LevelInformational)
	}

	beego.Run()
}
func init() {
	showNumberLine, _ := beego.AppConfig.Bool("logger.numberLine")
	levelString := beego.AppConfig.String("logger.level")
	logModels := beego.AppConfig.Strings("logger.logger")
	for _, logModel := range logModels {
		if logModel == "console" {
			beego.SetLogger("console", "")
		}
		if logModel == "file" {
			filename := beego.AppConfig.String("logger.filename")
			config := fmt.Sprintf(`{"filename":"%s","maxdays":30}`, filename)
			beego.SetLogger("file", config)
		}
	}
	if showNumberLine {
		beego.SetLogFuncCall(showNumberLine)
	}
	level, _ := Levelify(levelString)
	beego.SetLevel(level)
}
Exemple #24
0
func init() {
	// Try to have highest performance.
	runtime.GOMAXPROCS(runtime.NumCPU())

	// Set application log level.
	if beego.AppConfig.String("runmode") == "pro" {
		beego.SetLevel(beego.LevelInfo)
	}

	beego.Info("Go Walker", VERSION)

	// ----- Initialize log file -----
	os.Mkdir("./log", os.ModePerm)
	filew := beego.NewFileWriter("log/log.log", true)
	err := filew.StartLogger()
	if err != nil {
		beego.Critical("NewFileWriter ->", err)
	}

	doc.SetGithubCredentials(beego.AppConfig.String("client_id"), beego.AppConfig.String("client_secret"))
}
Exemple #25
0
func init() {
	runtime.GOMAXPROCS(runtime.NumCPU())

	// Set App version and log level.
	routers.AppVer = "v" + APP_VER

	if beego.AppConfig.String("runmode") == "pro" {
		beego.SetLevel(beego.LevelInfo)

		beego.Info("Go Walker Server", APP_VER)

		os.Mkdir("../log", os.ModePerm)
		fw := beego.NewFileWriter("../log/log", true)
		err := fw.StartLogger()
		if err != nil {
			beego.Critical("NewFileWriter ->", err)
		}
	}

	doc.SetGithubCredentials(utils.Cfg.MustValue("github", "client_id"),
		utils.Cfg.MustValue("github", "client_secret"))
}
Exemple #26
0
// We have to call a initialize function manully
// because we use `bee bale` to pack static resources
// and we cannot make sure that which init() execute first.
func initialize() {
	// Load configuration, set app version and log level.
	utils.LoadConfig("conf/app.ini")

	// Load locale files.
	langs := strings.Split(utils.Cfg.MustValue("lang", "types"), "|")
	// Skip en-US.
	for i := 1; i < len(langs); i++ {
		err := i18n.SetMessage(langs[i], "conf/locale_"+langs[i]+".ini")
		if err != nil {
			panic("Fail to set message file: " + err.Error())
		}
	}

	// Trim 4th part.
	routers.AppVer = strings.Join(strings.Split(APP_VER, ".")[:3], ".")

	beego.AppName = utils.Cfg.MustValue("beego", "app_name")
	beego.RunMode = utils.Cfg.MustValue("beego", "run_mode")
	beego.HttpPort = utils.Cfg.MustInt("beego", "http_port_"+beego.RunMode)

	routers.IsBeta = utils.Cfg.MustBool("server", "beta")
	routers.IsProMode = beego.RunMode == "prod"
	if routers.IsProMode {
		beego.SetLevel(beego.LevelInfo)
		beego.Info("Product mode enabled")

		os.Mkdir("./log", os.ModePerm)
		beego.BeeLogger.SetLogger("file", `{"filename": "log/log"}`)
	}

	// Initialize data.
	models.InitDb()
	routers.InitRouter()

	doc.SetGithubCredentials(utils.Cfg.MustValue("github", "client_id"),
		utils.Cfg.MustValue("github", "client_secret"))
}
Exemple #27
0
func initialize() {

	models.InitModels()

	// Set App version and log level.
	beego.AppName = models.Cfg.MustValue("beego", "app_name")
	beego.RunMode = models.Cfg.MustValue("beego", "run_mode")

	controllers.IsPro = beego.RunMode == "prod"
	if controllers.IsPro {
		beego.SetLevel(beego.LevelInfo)
		os.Mkdir("./log", os.ModePerm)
		beego.BeeLogger.SetLogger("file", `{"filename": "log/log"}`)
	}

	beego.SessionOn = true
	beego.SessionProvider = "redis"
	beego.SessionSavePath = "127.0.0.1:6379"
	beego.SessionGCMaxLifetime = 300
	beego.SessionName = "blogSid"

	controllers.InitApp()
}
Exemple #28
0
func main() {

	m.Connect()
	beego.ViewsPath = "views"
	beego.TemplateLeft = "<<<"
	beego.TemplateRight = ">>>"

	beego.AddTemplateExt("html")
	beego.SetStaticPath("/public", "public")

	beego.SetLogger("file", `{"filename":"logs/finprocess.log"}`)
	beego.SetLogFuncCall(true)

	logLevel, _ := beego.AppConfig.Int("log_level")
	beego.SetLevel(logLevel)

	//minutes for duration
	duration, _ := beego.AppConfig.Int("task_duration")

	go tasks.DailyTaskInit(duration) //启动task

	beego.Run()

}
Exemple #29
0
func main() {
	beego.Info("ModuleAB server", version.Version, "starting...")
	logfile := beego.AppConfig.String("logFile")
	if logfile == "" {
		logfile = "logs/moduleab_server.log"
	}
	err := beego.SetLogger("file", fmt.Sprintf(`{"filename":"%s"}`, logfile))
	if err != nil {
		panic(err)
	}
	beego.SetLevel(beego.LevelInformational)

	beego.Info("Hello!")

	// 别用root运行我!
	if os.Getuid() == 0 {
		beego.Alert("Hey! You're running this server with user root!")
		panic("Don't run me with root!")
	}

	switch beego.BConfig.RunMode {
	case "initdb":
		beego.Info("Got runmode: Initialize database")
		err = orm.RunSyncdb("default", true, true)
		orm.Debug = true
		policies.InitDb()
		beego.Info("Database is ready")
		os.Exit(0)

	case "dev":
		beego.Info("Got runmode: Development")
		beego.SetLevel(beego.LevelDebug)
		beego.BConfig.WebConfig.DirectoryIndex = true
		beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"

		beego.Debug("Now import database")
		orm.Debug = true
		err = orm.RunSyncdb("default", false, true)

	case "deb":
		beego.Info("Got runmode: Debug")
		beego.SetLevel(beego.LevelDebug)

		beego.Debug("Now import database")
		orm.Debug = true
		err = orm.RunSyncdb("default", false, true)

	default:
		beego.BeeLogger.DelLogger("console")
		err = orm.RunSyncdb("default", false, false)
	}
	if err != nil {
		beego.Alert("Database error:", err, ". go exit.")
		os.Exit(1)
	}
	beego.Debug("Current PID:", os.Getpid())
	ioutil.WriteFile(
		beego.AppConfig.String("pidFile"),
		[]byte(fmt.Sprint(os.Getpid())),
		0600,
	)
	beego.Info("Run check oas job...")
	go policies.CheckOasJob()
	beego.Info("All is ready, go running...")
	beego.BConfig.WebConfig.Session.SessionOn = true
	beego.BConfig.WebConfig.Session.SessionName = "Session_MobuleAB"
	beego.Run()
	defer func() {
		x := recover()
		if x != nil {
			beego.Error("Got fatal error:", x)
			stack := make([]byte, 0)
			runtime.Stack(stack, true)
			beego.Error("Stack trace:\n", string(stack))
			os.Exit(1)
		}
	}()
}
Exemple #30
0
// LoadConfig loads configuration file.
func LoadConfig() *goconfig.ConfigFile {
	var err error

	if fh, _ := os.OpenFile(AppConfPath, os.O_RDONLY|os.O_CREATE, 0600); fh != nil {
		fh.Close()
	}

	// Load configuration, set app version and log level.
	Cfg, err = goconfig.LoadConfigFile(GlobalConfPath)

	if Cfg == nil {
		Cfg, err = goconfig.LoadConfigFile(AppConfPath)
		if err != nil {
			fmt.Println("Fail to load configuration file: " + err.Error())
			os.Exit(2)
		}

	} else {
		Cfg.AppendFiles(AppConfPath)
	}

	Cfg.BlockMode = false

	// set time zone of wetalk system
	TimeZone = Cfg.MustValue("app", "time_zone", "UTC")
	if _, err := time.LoadLocation(TimeZone); err == nil {
		os.Setenv("TZ", TimeZone)
	} else {
		fmt.Println("Wrong time_zone: " + TimeZone + " " + err.Error())
		os.Exit(2)
	}

	// Trim 4th part.
	AppVer = strings.Join(strings.Split(APP_VER, ".")[:3], ".")

	beego.RunMode = Cfg.MustValue("app", "run_mode")
	beego.HttpPort = Cfg.MustInt("app", "http_port")

	IsProMode = beego.RunMode == "pro"
	if IsProMode {
		beego.SetLevel(beego.LevelInfo)
	}

	// cache system
	Cache, err = cache.NewCache("memory", `{"interval":360}`)

	Captcha = captcha.NewCaptcha("/captcha/", Cache)
	Captcha.FieldIdName = "CaptchaId"
	Captcha.FieldCaptchaName = "Captcha"

	// session settings
	beego.SessionOn = true
	beego.SessionProvider = Cfg.MustValue("session", "session_provider", "file")
	beego.SessionSavePath = Cfg.MustValue("session", "session_path", "sessions")
	beego.SessionName = Cfg.MustValue("session", "session_name", "wetalk_sess")
	beego.SessionCookieLifeTime = Cfg.MustInt("session", "session_life_time", 0)
	beego.SessionGCMaxLifetime = Cfg.MustInt64("session", "session_gc_time", 86400)

	beego.EnableXSRF = true
	// xsrf token expire time
	beego.XSRFExpire = 86400 * 365

	driverName := Cfg.MustValue("orm", "driver_name", "mysql")
	dataSource := Cfg.MustValue("orm", "data_source", "root:root@/wetalk?charset=utf8&loc=UTC")
	maxIdle := Cfg.MustInt("orm", "max_idle_conn", 30)
	maxOpen := Cfg.MustInt("orm", "max_open_conn", 50)

	// set default database
	err = orm.RegisterDataBase("default", driverName, dataSource, maxIdle, maxOpen)
	if err != nil {
		beego.Error(err)
	}
	orm.RunCommand()

	err = orm.RunSyncdb("default", false, false)
	if err != nil {
		beego.Error(err)
	}

	reloadConfig()

	if SphinxEnabled {
		// for search config
		SphinxHost = Cfg.MustValue("search", "sphinx_host", "127.0.0.1:9306")
		SphinxMaxConn = Cfg.MustInt("search", "sphinx_max_conn", 5)
		orm.RegisterDriver("sphinx", orm.DR_MySQL)
	}

	social.DefaultAppUrl = AppUrl

	// OAuth
	var clientId, secret string

	clientId = Cfg.MustValue("oauth", "github_client_id", "your_client_id")
	secret = Cfg.MustValue("oauth", "github_client_secret", "your_client_secret")
	GithubAuth = apps.NewGithub(clientId, secret)

	clientId = Cfg.MustValue("oauth", "google_client_id", "your_client_id")
	secret = Cfg.MustValue("oauth", "google_client_secret", "your_client_secret")
	GoogleAuth = apps.NewGoogle(clientId, secret)

	err = social.RegisterProvider(GithubAuth)
	if err != nil {
		beego.Error(err)
	}
	err = social.RegisterProvider(GoogleAuth)
	if err != nil {
		beego.Error(err)
	}

	settingLocales()
	settingCompress()

	configWatcher()

	return Cfg
}