Просмотр исходного кода

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

xuxueli 6 лет назад
Родитель
Сommit
7d9f677948

+ 3 - 2
doc/XXL-JOB官方文档.md Просмотреть файл

1241
 - 25、任务调度备注中标注任务触发类型,如Cron触发、父任务触发、API触发等等,方便排查调度日志;
1241
 - 25、任务调度备注中标注任务触发类型,如Cron触发、父任务触发、API触发等等,方便排查调度日志;
1242
 - 26、底层日志组件SimpleDateFormat线程安全问题修复;
1242
 - 26、底层日志组件SimpleDateFormat线程安全问题修复;
1243
 - 27、执行器通讯线程优化,corePoolSize从256降低至32;
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
 ### TODO LIST
1249
 ### TODO LIST

+ 18 - 1
xxl-job-core/src/main/java/com/xxl/job/core/handler/impl/ScriptJobHandler.java Просмотреть файл

25
         this.glueUpdatetime = glueUpdatetime;
25
         this.glueUpdatetime = glueUpdatetime;
26
         this.gluesource = gluesource;
26
         this.gluesource = gluesource;
27
         this.glueType = glueType;
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
     public long getGlueUpdatetime() {
44
     public long getGlueUpdatetime() {
48
                 .concat("_")
62
                 .concat("_")
49
                 .concat(String.valueOf(glueUpdatetime))
63
                 .concat(String.valueOf(glueUpdatetime))
50
                 .concat(glueType.getSuffix());
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
         // log file
70
         // log file
54
         String logFileName = XxlJobFileAppender.contextHolder.get();
71
         String logFileName = XxlJobFileAppender.contextHolder.get();