Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 修复文件打开后未关闭的bug #125

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func newOptions(opts ...module.Option) module.Options {
}
ApplicationDir := ""
if opt.WorkDir != "" {
_, err := os.Open(opt.WorkDir)
_, err := os.Stat(opt.WorkDir)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -155,28 +155,25 @@ func newOptions(opts ...module.Option) module.Options {
}
}

_, err := os.Open(opt.ConfPath)
if err != nil {
if _, err := os.Stat(opt.ConfPath); err != nil {
//文件不存在
panic(fmt.Sprintf("config path error %v", err))
}
_, err = os.Open(opt.LogDir)
if err != nil {
if _, err := os.Stat(opt.LogDir); err != nil {
//文件不存在
err := os.Mkdir(opt.LogDir, os.ModePerm) //
err := os.Mkdir(opt.LogDir, os.ModePerm)
if err != nil {
fmt.Println(err)
}
}

_, err = os.Open(opt.BIDir)
if err != nil {
if _, err := os.Stat(opt.BIDir); err != nil {
//文件不存在
err := os.Mkdir(opt.BIDir, os.ModePerm) //
err := os.Mkdir(opt.BIDir, os.ModePerm)
if err != nil {
fmt.Println(err)
}
}

return opt
}

Expand Down Expand Up @@ -209,14 +206,13 @@ type DefaultApp struct {

// Run 运行应用
func (app *DefaultApp) Run(mods ...module.Module) error {
f, err := os.Open(app.opts.ConfPath)
if err != nil {
if _, err := os.Stat(app.opts.ConfPath); err != nil {
//文件不存在
panic(fmt.Sprintf("config path error %v", err))
}
var cof conf.Config
fmt.Println("Server configuration path :", app.opts.ConfPath)
conf.LoadConfig(f.Name()) //加载配置文件
conf.LoadConfig(app.opts.ConfPath) //加载配置文件
cof = conf.Conf
app.Configure(cof) //解析配置信息

Expand Down