reverse from pull 330
Showing
2 changed files
with
13 additions
and
18 deletions
| ... | @@ -67,7 +67,15 @@ func InsertFilter(pattern string, pos int, filter FilterFunc) *App { | ... | @@ -67,7 +67,15 @@ func InsertFilter(pattern string, pos int, filter FilterFunc) *App { |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | func Run() { | 69 | func Run() { |
| 70 | InitConfig() | 70 | //if AppConfigPath not In the conf/app.conf reParse config |
| 71 | if AppConfigPath != path.Join(AppPath, "conf", "app.conf") { | ||
| 72 | err := ParseConfig() | ||
| 73 | if err != nil { | ||
| 74 | if RunMode == "dev" { | ||
| 75 | Warn(err) | ||
| 76 | } | ||
| 77 | } | ||
| 78 | } | ||
| 71 | 79 | ||
| 72 | if SessionOn { | 80 | if SessionOn { |
| 73 | GlobalSessions, _ = session.NewManager(SessionProvider, | 81 | GlobalSessions, _ = session.NewManager(SessionProvider, | ... | ... |
| ... | @@ -58,9 +58,9 @@ var ( | ... | @@ -58,9 +58,9 @@ var ( |
| 58 | AdminHttpPort int | 58 | AdminHttpPort int |
| 59 | ) | 59 | ) |
| 60 | 60 | ||
| 61 | func InitConfig() { | 61 | func init() { |
| 62 | // explicit call config.Init | ||
| 63 | os.Chdir(path.Dir(os.Args[0])) | 62 | os.Chdir(path.Dir(os.Args[0])) |
| 63 | BeeApp = NewApp() | ||
| 64 | AppPath = path.Dir(os.Args[0]) | 64 | AppPath = path.Dir(os.Args[0]) |
| 65 | StaticDir = make(map[string]string) | 65 | StaticDir = make(map[string]string) |
| 66 | TemplateCache = make(map[string]*template.Template) | 66 | TemplateCache = make(map[string]*template.Template) |
| ... | @@ -83,6 +83,7 @@ func InitConfig() { | ... | @@ -83,6 +83,7 @@ func InitConfig() { |
| 83 | MaxMemory = 1 << 26 //64MB | 83 | MaxMemory = 1 << 26 //64MB |
| 84 | EnableGzip = false | 84 | EnableGzip = false |
| 85 | StaticDir["/static"] = "static" | 85 | StaticDir["/static"] = "static" |
| 86 | AppConfigPath = path.Join(AppPath, "conf", "app.conf") | ||
| 86 | HttpServerTimeOut = 0 | 87 | HttpServerTimeOut = 0 |
| 87 | ErrorsShow = true | 88 | ErrorsShow = true |
| 88 | XSRFKEY = "beegoxsrf" | 89 | XSRFKEY = "beegoxsrf" |
| ... | @@ -93,17 +94,7 @@ func InitConfig() { | ... | @@ -93,17 +94,7 @@ func InitConfig() { |
| 93 | EnableAdmin = true | 94 | EnableAdmin = true |
| 94 | AdminHttpAddr = "localhost" | 95 | AdminHttpAddr = "localhost" |
| 95 | AdminHttpPort = 8088 | 96 | AdminHttpPort = 8088 |
| 96 | 97 | ParseConfig() | |
| 97 | // if AppConfigPath hasn't been set yet, | ||
| 98 | // use /Path/to/AppPath/conf/app.conf as the default | ||
| 99 | if AppConfigPath == "" { | ||
| 100 | AppConfigPath = path.Join(AppPath, "conf", "app.conf") | ||
| 101 | } | ||
| 102 | |||
| 103 | if err := ParseConfig(); err != nil { | ||
| 104 | panic(err) | ||
| 105 | } | ||
| 106 | |||
| 107 | runtime.GOMAXPROCS(runtime.NumCPU()) | 98 | runtime.GOMAXPROCS(runtime.NumCPU()) |
| 108 | } | 99 | } |
| 109 | 100 | ||
| ... | @@ -267,7 +258,3 @@ func ParseConfig() (err error) { | ... | @@ -267,7 +258,3 @@ func ParseConfig() (err error) { |
| 267 | } | 258 | } |
| 268 | return nil | 259 | return nil |
| 269 | } | 260 | } |
| 270 | |||
| 271 | func init() { | ||
| 272 | BeeApp = NewApp() | ||
| 273 | } | ... | ... |
-
Please register or sign in to post a comment