1
0
mirror of https://github.com/astaxie/beego.git synced 2025-07-11 06:31:03 +00:00

fix path issue

This commit is contained in:
coseyo
2016-01-24 00:18:16 +08:00
parent 57d522a96a
commit 4c1cfc1386
2 changed files with 13 additions and 4 deletions

View File

@ -103,6 +103,8 @@ var (
BConfig *Config
// AppConfig is the instance of Config, store the config information from file
AppConfig *beegoAppConfig
// AppPath is the absolute path to the app
AppPath string
// AppConfigPath is the path to the config files
AppConfigPath string
// AppConfigProvider is the provider for the config, default is ini
@ -179,9 +181,16 @@ func init() {
// ParseConfig parsed default config file.
// now only support ini, next will support json.
func ParseConfig() (err error) {
AppPath, _ := filepath.Abs(filepath.Dir(os.Args[0]))
workPath, _ := os.Getwd()
workPath, _ = filepath.Abs(workPath)
if workPath != AppPath {
os.Chdir(AppPath)
}
if AppConfigPath == "" {
// initialize default configurations
AppPath, _ := filepath.Abs(filepath.Dir(os.Args[0]))
AppConfigPath = filepath.Join(AppPath, "conf", "app.conf")
if !utils.FileExists(AppConfigPath) {
AppConfig = &beegoAppConfig{config.NewFakeConfig()}