Skip to content

Commit

Permalink
fix: 修正在无.env文件时导致崩溃的问题 (#1170)
Browse files Browse the repository at this point in the history
  • Loading branch information
PaienNate authored Dec 29, 2024
1 parent eb95e4f commit 169a113
Showing 1 changed file with 7 additions and 7 deletions.
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

0 comments on commit 169a113

Please sign in to comment.