Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
byit-myth-job
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liyuan
byit-myth-job
Commits
038c20ef
Commit
038c20ef
authored
Mar 04, 2020
by
guo_minglei@163.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改运行编码格式
parent
8108428a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
7 deletions
+8
-7
MythJobProcess.java
...com/byit/executor/jobExecutor/process/MythJobProcess.java
+4
-3
LogGobbler.java
...core/src/main/java/com/byit/executor/util/LogGobbler.java
+4
-4
No files found.
byit-myth-core/myth-executor-core/src/main/java/com/byit/executor/jobExecutor/process/MythJobProcess.java
View file @
038c20ef
...
@@ -10,7 +10,6 @@ import java.io.File;
...
@@ -10,7 +10,6 @@ import java.io.File;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.io.InputStreamReader
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Field
;
import
java.nio.charset.StandardCharsets
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.Objects
;
...
@@ -108,8 +107,8 @@ public class MythJobProcess implements Callable<String>{
...
@@ -108,8 +107,8 @@ public class MythJobProcess implements Callable<String>{
log
.
info
(
"进程的id "
+
this
.
processId
);
log
.
info
(
"进程的id "
+
this
.
processId
);
}
}
outputGobbler
=
new
LogGobbler
(
new
InputStreamReader
(
this
.
process
.
getInputStream
(),
StandardCharsets
.
UTF_8
),
Boolean
.
FALSE
,
30
);
outputGobbler
=
new
LogGobbler
(
new
InputStreamReader
(
this
.
process
.
getInputStream
(),
"GB2312"
),
Boolean
.
FALSE
,
30
);
errorGobbler
=
new
LogGobbler
(
new
InputStreamReader
(
this
.
process
.
getErrorStream
(),
StandardCharsets
.
UTF_8
),
Boolean
.
TRUE
,
30
);
errorGobbler
=
new
LogGobbler
(
new
InputStreamReader
(
this
.
process
.
getErrorStream
(),
"GB2312"
),
Boolean
.
TRUE
,
30
);
//开始获取进程的运行日志
//开始获取进程的运行日志
outputGobbler
.
start
();
outputGobbler
.
start
();
errorGobbler
.
start
();
errorGobbler
.
start
();
...
@@ -141,6 +140,8 @@ public class MythJobProcess implements Callable<String>{
...
@@ -141,6 +140,8 @@ public class MythJobProcess implements Callable<String>{
if
(
this
.
process
.
isAlive
()){
if
(
this
.
process
.
isAlive
()){
this
.
process
.
destroy
();
this
.
process
.
destroy
();
}
}
System
.
out
.
println
(
outputGobbler
.
getRecentLog
());
System
.
out
.
println
(
errorGobbler
.
getRecentLog
());
return
outputGobbler
.
getRecentLog
()
+
"\n"
+
errorGobbler
.
getRecentLog
();
return
outputGobbler
.
getRecentLog
()
+
"\n"
+
errorGobbler
.
getRecentLog
();
}
}
}
}
...
...
byit-myth-core/myth-executor-core/src/main/java/com/byit/executor/util/LogGobbler.java
View file @
038c20ef
...
@@ -5,6 +5,7 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -5,6 +5,7 @@ import lombok.extern.slf4j.Slf4j;
import
java.io.BufferedReader
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.Reader
;
import
java.io.Reader
;
import
java.io.UnsupportedEncodingException
;
/**
/**
* @description: 获取运行日志的线程
* @description: 获取运行日志的线程
...
@@ -16,12 +17,12 @@ public class LogGobbler extends Thread {
...
@@ -16,12 +17,12 @@ public class LogGobbler extends Thread {
private
final
BufferedReader
inputReader
;
private
final
BufferedReader
inputReader
;
private
final
boolean
isError
;
private
final
boolean
isError
;
private
final
StringBu
ff
er
buffer
;
private
final
StringBu
ild
er
buffer
;
public
LogGobbler
(
final
Reader
inputReader
,
final
boolean
isError
,
final
int
bufferLines
)
{
public
LogGobbler
(
final
Reader
inputReader
,
final
boolean
isError
,
final
int
bufferLines
)
{
this
.
inputReader
=
new
BufferedReader
(
inputReader
);
this
.
inputReader
=
new
BufferedReader
(
inputReader
);
this
.
isError
=
isError
;
this
.
isError
=
isError
;
this
.
buffer
=
new
StringBu
ff
er
(
bufferLines
);
this
.
buffer
=
new
StringBu
ild
er
(
bufferLines
);
}
}
@Override
@Override
...
@@ -32,7 +33,6 @@ public class LogGobbler extends Thread {
...
@@ -32,7 +33,6 @@ public class LogGobbler extends Thread {
if
(
line
==
null
)
{
if
(
line
==
null
)
{
return
;
return
;
}
}
this
.
buffer
.
append
(
line
+
"\n"
);
this
.
buffer
.
append
(
line
+
"\n"
);
printLog
(
line
);
printLog
(
line
);
}
}
...
@@ -62,7 +62,7 @@ public class LogGobbler extends Thread {
...
@@ -62,7 +62,7 @@ public class LogGobbler extends Thread {
}
}
}
}
public
String
getRecentLog
()
{
public
String
getRecentLog
()
throws
UnsupportedEncodingException
{
return
buffer
.
toString
();
return
buffer
.
toString
();
}
}
...
...
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