fix(server): 修复服务器启动日志输出位置
- 将服务器启动成功的日志输出移至正确的执行流程位置 - 确保地址检查逻辑在日志输出之前正确执行 - 保持原有的地址判断和提示信息功能不变main
parent
af31b688cf
commit
6661ad7fb3
|
|
@ -54,13 +54,14 @@ func Run(g *gin.Engine) {
|
||||||
}
|
}
|
||||||
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 {
|
||||||
|
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