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

fix: 修正在无env文件时会导致崩溃的问题 #1170

Merged
merged 3 commits into from
Dec 29, 2024
Merged
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
14 changes: 7 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,8 @@ func main() {
LogLevel int8 `long:"log-level" description:"设置日志等级" default:"0" choice:"-1" choice:"0" choice:"1" choice:"2" choice:"3" choice:"4" choice:"5"`
ContainerMode bool `long:"container-mode" description:"容器模式,该模式下禁用内置客户端"`
}
// 读取env参数
err := godotenv.Load()
if err != nil {
log.Errorf("未读取到.env参数,若您未使用docker或第三方数据库,可安全忽略。")
}
_, err = flags.ParseArgs(&opts, os.Args)
// 读取命令行传参
_, err := flags.ParseArgs(&opts, os.Args)
if err != nil {
return
}
Expand All @@ -230,8 +226,12 @@ func main() {
paniclog.InitPanicLog()
// 3. 提示日志打印
log.Info("运行日志开始记录,海豹出现故障时可查看 data/main.log 与 data/panic.log 获取更多信息")
// 加载env相关
err = godotenv.Load()
if err != nil {
log.Errorf("未读取到.env参数,若您未使用docker或第三方数据库,可安全忽略。")
}
// 初始化文件加锁系统

locked, err := sealLock.TryLock()
// 如果有错误,或者未能取到锁
if err != nil || !locked {
Expand Down
Loading