Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
熊鹏飞
/
xxljob220
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ea5b3541
authored
Apr 28, 2018
by
xuxueli
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Glue(Shell) 等脚本任务支持失败重试;
parent
a4906197
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
5 deletions
doc/XXL-JOB官方文档.md
xxl-job-core/src/main/java/com/xxl/job/core/handler/impl/ScriptJobHandler.java
doc/XXL-JOB官方文档.md
View file @
ea5b3541
## 《分
布式任务调度平台XXL-JOB》
## 《分
布式任务调度平台XXL-JOB》
...
@@ -785,7 +785,7 @@ xxl-job-admin#com.xxl.job.admin.controller.JobApiController.callback
...
@@ -785,7 +785,7 @@ xxl-job-admin#com.xxl.job.admin.controller.JobApiController.callback
#### 5.5.3 GLUE模式(Shell) + GLUE模式(Python) + GLUE模式(NodeJS)
#### 5.5.3 GLUE模式(Shell) + GLUE模式(Python) + GLUE模式(NodeJS)
开发步骤:可参考 "章节三" ;
开发步骤:可参考 "章节三" ;
原理:脚本任务的源码托管在调度中心,脚本逻辑在执行器运行。当触发脚本任务时,执行器会加载脚本源码在执行器机器上生成一份脚本文件,然后通过Java代码调用该脚本;并且实时将脚本输出日志写到任务日志文件中,从而在调度中心可以实时监控脚本运行情况;
脚本返回码为0时表示执行成功,其他标示执行失败。
原理:脚本任务的源码托管在调度中心,脚本逻辑在执行器运行。当触发脚本任务时,执行器会加载脚本源码在执行器机器上生成一份脚本文件,然后通过Java代码调用该脚本;并且实时将脚本输出日志写到任务日志文件中,从而在调度中心可以实时监控脚本运行情况;
目前支持的脚本类型如下:
目前支持的脚本类型如下:
...
@@ -793,6 +793,7 @@ xxl-job-admin#com.xxl.job.admin.controller.JobApiController.callback
...
@@ -793,6 +793,7 @@ xxl-job-admin#com.xxl.job.admin.controller.JobApiController.callback
- python脚本:任务运行模式选择为 "GLUE模式(Python)"时支持 "python" 脚本任务;
- python脚本:任务运行模式选择为 "GLUE模式(Python)"时支持 "python" 脚本任务;
- nodejs脚本:务运行模式选择为 "GLUE模式(NodeJS)"时支持 "nodejs" 脚本任务;
- nodejs脚本:务运行模式选择为 "GLUE模式(NodeJS)"时支持 "nodejs" 脚本任务;
脚本任务通过 Exit Code 判断任务执行结果,状态码可参考章节 "5.15 任务执行结果说明";
#### 5.5.4 执行器
#### 5.5.4 执行器
执行器实际上是一个内嵌的Jetty服务器,默认端口9999(配置项:xxl.job.executor.port)。
执行器实际上是一个内嵌的Jetty服务器,默认端口9999(配置项:xxl.job.executor.port)。
...
@@ -917,6 +918,15 @@ echo "分片总数 total = $3"
...
@@ -917,6 +918,15 @@ echo "分片总数 total = $3"
-
3、等待B组机器任务运行结束并编译上线;执行器注册地址替换为A组+B组;
-
3、等待B组机器任务运行结束并编译上线;执行器注册地址替换为A组+B组;
操作结束;
操作结束;
### 5.15 任务执行结果说明
系统根据以下标准判断任务执行结果,可参考之。
-- | Bean/Glue(Java) | Glue(Shell) 等脚本任务
--- | --- | ---
成功 | IJobHandler.SUCCESS | 0
失败 | IJobHandler.FAIL | -1(其他)
失败重试 | IJobHandler.FAIL_RETRY | 501
## 六、版本更新日志
## 六、版本更新日志
### 6.1 版本 V1.1.x,新特性[2015-12-05]
### 6.1 版本 V1.1.x,新特性[2015-12-05]
...
@@ -1181,7 +1191,7 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
...
@@ -1181,7 +1191,7 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
-
3、
[
迭代中
]
任务超时设置,超时任务主动终止;
-
3、
[
迭代中
]
任务超时设置,超时任务主动终止;
-
4、任务属性枚举 "任务模式、阻塞策略" 国际化优化;
-
4、任务属性枚举 "任务模式、阻塞策略" 国际化优化;
-
5、任务日志表状态字段类型优化;
-
5、任务日志表状态字段类型优化;
-
6、
[
迭代中
]
脚本任务支持失败重试;
-
6、
Glue(Shell) 等
脚本任务支持失败重试;
-
7、告警邮箱支持SSL配置;
-
7、告警邮箱支持SSL配置;
-
8、Window机器下File.separator不兼容问题修复;
-
8、Window机器下File.separator不兼容问题修复;
...
...
xxl-job-core/src/main/java/com/xxl/job/core/handler/impl/ScriptJobHandler.java
View file @
ea5b3541
...
@@ -63,8 +63,15 @@ public class ScriptJobHandler extends IJobHandler {
...
@@ -63,8 +63,15 @@ public class ScriptJobHandler extends IJobHandler {
// invoke
// invoke
XxlJobLogger
.
log
(
"----------- script file:"
+
scriptFileName
+
" -----------"
);
XxlJobLogger
.
log
(
"----------- script file:"
+
scriptFileName
+
" -----------"
);
int
exitValue
=
ScriptUtil
.
execToFile
(
cmd
,
scriptFileName
,
logFileName
,
scriptParams
);
int
exitValue
=
ScriptUtil
.
execToFile
(
cmd
,
scriptFileName
,
logFileName
,
scriptParams
);
ReturnT
<
String
>
result
=
(
exitValue
==
0
)?
IJobHandler
.
SUCCESS
:
new
ReturnT
<
String
>(
IJobHandler
.
FAIL
.
getCode
(),
"script exit value("
+
exitValue
+
") is failed"
);
return
result
;
if
(
exitValue
==
0
)
{
return
IJobHandler
.
SUCCESS
;
}
else
if
(
exitValue
==
501
)
{
return
IJobHandler
.
FAIL_RETRY
;
}
else
{
return
new
ReturnT
<
String
>(
IJobHandler
.
FAIL
.
getCode
(),
"script exit value("
+
exitValue
+
") is failed"
);
}
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment