mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 03:50:54 +00:00
add workPath don't chdir when go run or go test
This commit is contained in:
parent
9c959fba4d
commit
bf0b1af64f
17
config.go
17
config.go
@ -11,12 +11,14 @@ import (
|
|||||||
"github.com/astaxie/beego/config"
|
"github.com/astaxie/beego/config"
|
||||||
"github.com/astaxie/beego/logs"
|
"github.com/astaxie/beego/logs"
|
||||||
"github.com/astaxie/beego/session"
|
"github.com/astaxie/beego/session"
|
||||||
|
"github.com/astaxie/beego/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
BeeApp *App // beego application
|
BeeApp *App // beego application
|
||||||
AppName string
|
AppName string
|
||||||
AppPath string
|
AppPath string
|
||||||
|
workPath string
|
||||||
AppConfigPath string
|
AppConfigPath string
|
||||||
StaticDir map[string]string
|
StaticDir map[string]string
|
||||||
TemplateCache map[string]*template.Template // template caching map
|
TemplateCache map[string]*template.Template // template caching map
|
||||||
@ -66,9 +68,20 @@ func init() {
|
|||||||
// create beego application
|
// create beego application
|
||||||
BeeApp = NewApp()
|
BeeApp = NewApp()
|
||||||
|
|
||||||
|
workPath, _ = os.Getwd()
|
||||||
|
workPath, _ = filepath.Abs(workPath)
|
||||||
// initialize default configurations
|
// initialize default configurations
|
||||||
AppPath, _ = filepath.Abs(filepath.Dir(os.Args[0]))
|
AppPath, _ = filepath.Abs(filepath.Dir(os.Args[0]))
|
||||||
os.Chdir(AppPath)
|
|
||||||
|
AppConfigPath = filepath.Join(AppPath, "conf", "app.conf")
|
||||||
|
|
||||||
|
if workPath != AppPath {
|
||||||
|
if utils.FileExists(AppConfigPath) {
|
||||||
|
os.Chdir(AppPath)
|
||||||
|
} else {
|
||||||
|
AppConfigPath = filepath.Join(workPath, "conf", "app.conf")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
StaticDir = make(map[string]string)
|
StaticDir = make(map[string]string)
|
||||||
StaticDir["/static"] = "static"
|
StaticDir["/static"] = "static"
|
||||||
@ -107,8 +120,6 @@ func init() {
|
|||||||
|
|
||||||
EnableGzip = false
|
EnableGzip = false
|
||||||
|
|
||||||
AppConfigPath = filepath.Join(AppPath, "conf", "app.conf")
|
|
||||||
|
|
||||||
HttpServerTimeOut = 0
|
HttpServerTimeOut = 0
|
||||||
|
|
||||||
ErrorsShow = true
|
ErrorsShow = true
|
||||||
|
Loading…
Reference in New Issue
Block a user