mirror of
https://github.com/astaxie/beego.git
synced 2024-11-26 12:01:29 +00:00
commit
6cc3d4470a
14
config.go
14
config.go
@ -103,6 +103,8 @@ var (
|
|||||||
BConfig *Config
|
BConfig *Config
|
||||||
// AppConfig is the instance of Config, store the config information from file
|
// AppConfig is the instance of Config, store the config information from file
|
||||||
AppConfig *beegoAppConfig
|
AppConfig *beegoAppConfig
|
||||||
|
// AppPath is the absolute path to the app
|
||||||
|
AppPath string
|
||||||
// AppConfigPath is the path to the config files
|
// AppConfigPath is the path to the config files
|
||||||
AppConfigPath string
|
AppConfigPath string
|
||||||
// AppConfigProvider is the provider for the config, default is ini
|
// AppConfigProvider is the provider for the config, default is ini
|
||||||
@ -111,9 +113,15 @@ var (
|
|||||||
TemplateCache map[string]*template.Template
|
TemplateCache map[string]*template.Template
|
||||||
// GlobalSessions is the instance for the session manager
|
// GlobalSessions is the instance for the session manager
|
||||||
GlobalSessions *session.Manager
|
GlobalSessions *session.Manager
|
||||||
|
|
||||||
|
workPath string
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
AppPath, _ = filepath.Abs(filepath.Dir(os.Args[0]))
|
||||||
|
workPath, _ = os.Getwd()
|
||||||
|
workPath, _ = filepath.Abs(workPath)
|
||||||
|
|
||||||
BConfig = &Config{
|
BConfig = &Config{
|
||||||
AppName: "beego",
|
AppName: "beego",
|
||||||
RunMode: DEV,
|
RunMode: DEV,
|
||||||
@ -181,13 +189,17 @@ func init() {
|
|||||||
func ParseConfig() (err error) {
|
func ParseConfig() (err error) {
|
||||||
if AppConfigPath == "" {
|
if AppConfigPath == "" {
|
||||||
// initialize default configurations
|
// initialize default configurations
|
||||||
AppPath, _ := filepath.Abs(filepath.Dir(os.Args[0]))
|
|
||||||
AppConfigPath = filepath.Join(AppPath, "conf", "app.conf")
|
AppConfigPath = filepath.Join(AppPath, "conf", "app.conf")
|
||||||
if !utils.FileExists(AppConfigPath) {
|
if !utils.FileExists(AppConfigPath) {
|
||||||
AppConfig = &beegoAppConfig{config.NewFakeConfig()}
|
AppConfig = &beegoAppConfig{config.NewFakeConfig()}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if workPath != AppPath {
|
||||||
|
os.Chdir(AppPath)
|
||||||
|
}
|
||||||
|
|
||||||
AppConfig, err = newAppConfig(AppConfigProvider, AppConfigPath)
|
AppConfig, err = newAppConfig(AppConfigProvider, AppConfigPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -130,7 +130,7 @@ func parserComments(comments *ast.CommentGroup, funcName, controllerName, pkgpat
|
|||||||
}
|
}
|
||||||
|
|
||||||
func genRouterCode() {
|
func genRouterCode() {
|
||||||
os.Mkdir("routers", 0755)
|
os.Mkdir(path.Join(AppPath, "routers"), 0755)
|
||||||
Info("generate router from comments")
|
Info("generate router from comments")
|
||||||
var (
|
var (
|
||||||
globalinfo string
|
globalinfo string
|
||||||
@ -172,7 +172,7 @@ func genRouterCode() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if globalinfo != "" {
|
if globalinfo != "" {
|
||||||
f, err := os.Create(path.Join("routers", commentFilename))
|
f, err := os.Create(path.Join(AppPath, "routers", commentFilename))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -182,7 +182,7 @@ func genRouterCode() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func compareFile(pkgRealpath string) bool {
|
func compareFile(pkgRealpath string) bool {
|
||||||
if !utils.FileExists(path.Join("routers", commentFilename)) {
|
if !utils.FileExists(path.Join(AppPath, "routers", commentFilename)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if utils.FileExists(lastupdateFilename) {
|
if utils.FileExists(lastupdateFilename) {
|
||||||
|
Loading…
Reference in New Issue
Block a user