diff --git a/udf-starter-core/src/main/java/org/itkk/udf/core/CleanLogFile.java b/udf-starter-core/src/main/java/org/itkk/udf/core/CleanLogFile.java new file mode 100644 index 0000000..ae95bff --- /dev/null +++ b/udf-starter-core/src/main/java/org/itkk/udf/core/CleanLogFile.java @@ -0,0 +1,53 @@ +package org.itkk.udf.core; + +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.ArrayUtils; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.util.Arrays; + +/** + * CleanLogFile + */ +@Component +@Slf4j +public class CleanLogFile { + + /** + * logFile + */ + @Value("${logging.file}") + private String logFile; + + /** + * 清理日志文件 + */ + @Scheduled(cron = "0 0 1 * * ?") + public void cleanLog() { + log.info("cleanLog begin : {}", logFile); + File file = new File(logFile); + if (file.exists()) { + File dir = file.getParentFile(); + if (dir.exists() && dir.isDirectory()) { + File[] files = dir.listFiles(); + if (ArrayUtils.isNotEmpty(files)) { + Arrays.stream(files).filter(f -> !logFile.equals(f.getAbsolutePath())).forEach(f -> { + try { + log.info("cleanLog : {}", f.getAbsolutePath()); + Files.delete(f.toPath()); + } catch (IOException e) { + log.warn("msg:", e); + } + }); + } + } + } + log.info("cleanLog end : {}", logFile); + } + +} diff --git a/udf-starter-file-aliyun-oss-api/src/main/java/org/itkk/udf/file/aliyun/oss/api/download/DownLoadProcessAspect.java b/udf-starter-file-aliyun-oss-api/src/main/java/org/itkk/udf/file/aliyun/oss/api/download/DownLoadProcessAspect.java index f0223e8..3ba94cb 100644 --- a/udf-starter-file-aliyun-oss-api/src/main/java/org/itkk/udf/file/aliyun/oss/api/download/DownLoadProcessAspect.java +++ b/udf-starter-file-aliyun-oss-api/src/main/java/org/itkk/udf/file/aliyun/oss/api/download/DownLoadProcessAspect.java @@ -42,9 +42,9 @@ public class DownLoadProcessAspect { public static final String DOWNLOAD_CACHE_PREFIX = "DOWNLOAD_CACHE:"; /** - * DOWNLOAD_WAITING_CACHE_EXPIRATION(待执行,执行中,缓存过期时间为1小时) + * DOWNLOAD_WAITING_CACHE_EXPIRATION(待执行,执行中,缓存过期时间为30分钟) */ - public static final long DOWNLOAD_WAITING_CACHE_EXPIRATION = 60L * 1L; + public static final long DOWNLOAD_WAITING_CACHE_EXPIRATION = 30L; /** * DOWNLOAD_CACHE_EXPIRATION(执行完成,执行错误,缓存过期时间为1分钟)