fix(server): 修复服务器启动成功后的日志输出逻辑
- 修复了服务器启动成功消息的条件判断逻辑 - 确保服务器正常启动时显示正确的访问地址提示 - 改进了 localhost 地址检测和显示格式 - 优化了代码执行流程避免异常退出时的错误提示main
parent
6661ad7fb3
commit
5d7e584ffd
|
|
@ -53,15 +53,16 @@ func Run(g *gin.Engine) {
|
||||||
log.Error("服务器启动失败:", err)
|
log.Error("服务器启动失败:", err)
|
||||||
}
|
}
|
||||||
os.Exit(1) // 启动失败则退出程序
|
os.Exit(1) // 启动失败则退出程序
|
||||||
}
|
|
||||||
|
|
||||||
log.Info("服务器启动成功....")
|
|
||||||
if strings.Contains(s.Addr, "127.0.0.1") || strings.Contains(s.Addr, "0.0.0.0") || strings.Contains(s.Addr, "locahost") {
|
|
||||||
log.Info("请使用打开:", fmt.Sprintf("http://%s\n", s.Addr))
|
|
||||||
} else {
|
} else {
|
||||||
log.Info("请使用打开:", fmt.Sprintf("http://localhost%s\n", s.Addr))
|
log.Info("服务器启动成功....")
|
||||||
|
if strings.Contains(s.Addr, "127.0.0.1") || strings.Contains(s.Addr, "0.0.0.0") || strings.Contains(s.Addr, "locahost") {
|
||||||
|
log.Info("请使用打开:", fmt.Sprintf("http://%s\n", s.Addr))
|
||||||
|
} else {
|
||||||
|
log.Info("请使用打开:", fmt.Sprintf("http://localhost%s\n", s.Addr))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// 等待中断信号以优雅地关闭服务器
|
// 等待中断信号以优雅地关闭服务器
|
||||||
quit := make(chan os.Signal, 1)
|
quit := make(chan os.Signal, 1)
|
||||||
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
|
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue