diff --git a/dsBaseRpc/main.go b/dsBaseRpc/main.go index 9be4a415..d7c3c8b1 100644 --- a/dsBaseRpc/main.go +++ b/dsBaseRpc/main.go @@ -46,8 +46,8 @@ func main() { fmt.Print(logo) //创建日志文件目录 - if !CommonUtil.Exists(ConfigUtil.DistributeRemotePath+"Logs"){ - os.MkdirAll(ConfigUtil.DistributeRemotePath+"Logs",os.ModePerm) + if !CommonUtil.Exists(ConfigUtil.DistributeRemotePath + "Logs") { + os.MkdirAll(ConfigUtil.DistributeRemotePath+"Logs", os.ModePerm) } //添加定时清理垃圾的代码 @@ -60,6 +60,15 @@ func main() { sql = "truncate table t_base_student_import_excel" db.SQL(sql).Execute() + + //清空自动日志 + var logPath = ConfigUtil.DistributeRemotePath + "Logs" + file := logPath + "/dsBaseRpc.log" + if CommonUtil.Exists(file) { + f, _ := os.OpenFile(file, os.O_WRONLY|os.O_TRUNC, 0600) + defer f.Close() + f.WriteString("清空成功!") + } }) c.Start() defer c.Stop()