1
0
mirror of https://github.com/astaxie/beego.git synced 2024-12-22 20:20:49 +00:00

panic if parse failed

This commit is contained in:
Pengfei Xue 2013-12-04 23:53:36 +08:00
parent fb6312a303
commit 420e816bed
2 changed files with 37 additions and 9 deletions

View File

@ -67,13 +67,12 @@ func InsertFilter(pattern string, pos int, filter FilterFunc) *App {
}
func Run() {
//if AppConfigPath not In the conf/app.conf reParse config
// if AppConfigPath not In the conf/app.conf reParse config
if AppConfigPath != path.Join(AppPath, "conf", "app.conf") {
err := ParseConfig()
if err != nil {
if RunMode == "dev" {
Warn(err)
}
// configuration is critical to app, panic here if parse failed
panic(err)
}
}

View File

@ -59,18 +59,32 @@ var (
)
func init() {
os.Chdir(path.Dir(os.Args[0]))
// create beeapp
BeeApp = NewApp()
// initialize default configurations
os.Chdir(path.Dir(os.Args[0]))
AppPath = path.Dir(os.Args[0])
StaticDir = make(map[string]string)
StaticDir["/static"] = "static"
TemplateCache = make(map[string]*template.Template)
HttpAddr = ""
// set this to 0.0.0.0 to make this app available to externally
HttpAddr = "127.0.0.1"
HttpPort = 8080
AppName = "beego"
RunMode = "dev" //default runmod
AutoRender = true
RecoverPanic = true
ViewsPath = "views"
SessionOn = false
SessionProvider = "memory"
SessionName = "beegosessionID"
@ -79,23 +93,38 @@ func init() {
SessionHashFunc = "sha1"
SessionHashKey = "beegoserversessionkey"
SessionCookieLifeTime = 3600
UseFcgi = false
MaxMemory = 1 << 26 //64MB
EnableGzip = false
StaticDir["/static"] = "static"
AppConfigPath = path.Join(AppPath, "conf", "app.conf")
HttpServerTimeOut = 0
ErrorsShow = true
XSRFKEY = "beegoxsrf"
XSRFExpire = 0
TemplateLeft = "{{"
TemplateRight = "}}"
BeegoServerName = "beegoServer"
EnableAdmin = true
AdminHttpAddr = "localhost"
AdminHttpAddr = "127.0.0.1"
AdminHttpPort = 8088
ParseConfig()
runtime.GOMAXPROCS(runtime.NumCPU())
err := ParseConfig()
if err != nil && !os.IsNotExist(err) {
// panic unless the err is can not find default configuration file
panic(err)
}
}
func ParseConfig() (err error) {