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
b30fceb4
authored
Apr 27, 2017
by
xueli.xue
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
脚本,输入输出
parent
a3bef921
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
8 deletions
xxl-job-admin/src/main/webapp/WEB-INF/template/jobinfo/jobinfo.index.ftl
xxl-job-admin/src/main/webapp/static/js/jobinfo.index.1.js
xxl-job-core/src/main/java/com/xxl/job/core/handler/impl/ScriptJobHandler.java
xxl-job-core/src/main/java/com/xxl/job/core/util/ScriptUtil.java
xxl-job-admin/src/main/webapp/WEB-INF/template/jobinfo/jobinfo.index.ftl
View file @
b30fceb4
...
...
@@ -192,16 +192,18 @@ public class DemoGlueJobHandler extends IJobHandler {
</textarea>
<textarea
class=
"glueSource_shell"
style=
"display:none;"
>
#!/bin/bash
echo "xxl-job: hello shell"
for item in 1 2 3
echo "脚本位置:$0"
echo "参数数量:$#"
for param in $*
do
echo "
shell : $ite
m"
echo "
参数 : $para
m"
sleep 1s
done
echo "Good bye!"
exit 0
</textarea>
<textarea
class=
"glueSource_python"
style=
"display:none;"
>
#!/usr/bin/python
...
...
xxl-job-admin/src/main/webapp/static/js/jobinfo.index.1.js
View file @
b30fceb4
...
...
@@ -304,7 +304,7 @@ $(function() {
});
//
GLUE模式开启
//
运行模式
$
(
".glueType"
).
change
(
function
(){
// executorHandler
var
$executorHandler
=
$
(
this
).
parents
(
"form"
).
find
(
"input[name='executorHandler']"
);
...
...
xxl-job-core/src/main/java/com/xxl/job/core/handler/impl/ScriptJobHandler.java
View file @
b30fceb4
...
...
@@ -48,8 +48,9 @@ public class ScriptJobHandler extends IJobHandler {
String
logFileName
=
XxlJobFileAppender
.
filePath
.
concat
(
XxlJobFileAppender
.
contextHolder
.
get
());
// invoke
ScriptUtil
.
execToFile
(
cmd
,
scriptFileName
,
logFileName
);
return
ReturnT
.
SUCCESS
;
int
exitValue
=
ScriptUtil
.
execToFile
(
cmd
,
scriptFileName
,
logFileName
,
params
);
ReturnT
<
String
>
result
=
(
exitValue
==
0
)?
ReturnT
.
SUCCESS
:
new
ReturnT
<
String
>(
ReturnT
.
FAIL_CODE
,
"script exit value("
+
exitValue
+
") is failed"
);
return
result
;
}
}
xxl-job-core/src/main/java/com/xxl/job/core/util/ScriptUtil.java
View file @
b30fceb4
...
...
@@ -65,8 +65,11 @@ public class ScriptUtil {
* @param command
* @param scriptFile
* @param logFile
* @param params
* @return
* @throws IOException
*/
public
static
void
execToFile
(
String
command
,
String
scriptFile
,
String
logFile
)
throws
IOException
{
public
static
int
execToFile
(
String
command
,
String
scriptFile
,
String
logFile
,
String
...
params
)
throws
IOException
{
// 标准输出:print (null if watchdog timeout)
// 错误输出:logging + 异常 (still exists if watchdog timeout)
// 标准输入
...
...
@@ -76,12 +79,16 @@ public class ScriptUtil {
// command
CommandLine
commandline
=
new
CommandLine
(
command
);
commandline
.
addArgument
(
scriptFile
);
if
(
params
!=
null
&&
params
.
length
>
0
)
{
commandline
.
addArguments
(
params
);
}
// exec
DefaultExecutor
exec
=
new
DefaultExecutor
();
exec
.
setExitValues
(
null
);
exec
.
setStreamHandler
(
streamHandler
);
int
exitValue
=
exec
.
execute
(
commandline
);
int
exitValue
=
exec
.
execute
(
commandline
);
// exit code: 0=success, 1/-1=fail
return
exitValue
;
}
}
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