소스 검색

GLUE脚本文件自动清理功能,及时清理过期脚本文件;

xuxueli 6 년 전
부모
커밋
7d9f677948
2개의 변경된 파일21개의 추가작업 그리고 3개의 파일을 삭제
  1. 3 2
      doc/XXL-JOB官方文档.md
  2. 18 1
      xxl-job-core/src/main/java/com/xxl/job/core/handler/impl/ScriptJobHandler.java

+ 3 - 2
doc/XXL-JOB官方文档.md 파일 보기

@@ -1241,8 +1241,9 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
1241 1241
 - 25、任务调度备注中标注任务触发类型,如Cron触发、父任务触发、API触发等等,方便排查调度日志;
1242 1242
 - 26、底层日志组件SimpleDateFormat线程安全问题修复;
1243 1243
 - 27、执行器通讯线程优化,corePoolSize从256降低至32;
1244
-- 28、【迭代中】新增任务运行模式 "GLUE模式(PowerShell) ",支持PowerShell脚本任务;
1245
-- 29、【迭代中】分片任务失败重试优化,仅重试当前失败的分片;
1244
+- 28、新增任务运行模式 "GLUE模式(PowerShell) ",支持PowerShell脚本任务;
1245
+- 29、GLUE脚本文件自动清理功能,及时清理过期脚本文件;
1246
+- 30、【迭代中】分片任务失败重试优化,仅重试当前失败的分片;
1246 1247
 
1247 1248
 
1248 1249
 ### TODO LIST

+ 18 - 1
xxl-job-core/src/main/java/com/xxl/job/core/handler/impl/ScriptJobHandler.java 파일 보기

@@ -25,6 +25,20 @@ public class ScriptJobHandler extends IJobHandler {
25 25
         this.glueUpdatetime = glueUpdatetime;
26 26
         this.gluesource = gluesource;
27 27
         this.glueType = glueType;
28
+
29
+        // clean old script file
30
+        File glueSrcPath = new File(XxlJobFileAppender.getGlueSrcPath());
31
+        if (glueSrcPath.exists()) {
32
+            File[] glueSrcFileList = glueSrcPath.listFiles();
33
+            if (glueSrcFileList!=null && glueSrcFileList.length>0) {
34
+                for (File glueSrcFileItem : glueSrcFileList) {
35
+                    if (glueSrcFileItem.getName().startsWith(String.valueOf(jobId)+"_")) {
36
+                        glueSrcFileItem.delete();
37
+                    }
38
+                }
39
+            }
40
+        }
41
+
28 42
     }
29 43
 
30 44
     public long getGlueUpdatetime() {
@@ -48,7 +62,10 @@ public class ScriptJobHandler extends IJobHandler {
48 62
                 .concat("_")
49 63
                 .concat(String.valueOf(glueUpdatetime))
50 64
                 .concat(glueType.getSuffix());
51
-        ScriptUtil.markScriptFile(scriptFileName, gluesource);
65
+        File scriptFile = new File(scriptFileName);
66
+        if (!scriptFile.exists()) {
67
+            ScriptUtil.markScriptFile(scriptFileName, gluesource);
68
+        }
52 69
 
53 70
         // log file
54 71
         String logFileName = XxlJobFileAppender.contextHolder.get();