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
787cd9f8
Commit
787cd9f8
authored
Apr 21, 2020
by
guo_minglei@163.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改执行命令
parent
bf978c32
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
1 deletion
+61
-1
ScriptExecutorServiceImpl.java
...main/java/com/byit/service/ScriptExecutorServiceImpl.java
+2
-1
CmdUtil.java
...executor-server/src/main/java/com/byit/utils/CmdUtil.java
+59
-0
No files found.
byit-myth-executor/myth-executor-server/src/main/java/com/byit/service/ScriptExecutorServiceImpl.java
View file @
787cd9f8
...
...
@@ -15,6 +15,7 @@ import com.byit.job.utils.PlaceholderUtils;
import
com.byit.dto.web.ReturnResult
;
import
com.byit.pool.RunThreadPool
;
import
com.byit.rpc.remoting.provider.annotation.RpcService
;
import
com.byit.utils.CmdUtil
;
import
com.byit.utils.ServiceInfoUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.csource.common.MyException
;
...
...
@@ -106,7 +107,7 @@ public class ScriptExecutorServiceImpl implements ScriptExecutorService {
if
(
scriptParamAndPlaceholderDto
!=
null
){
command
=
PlaceholderUtils
.
commandReplace
(
command
,
scriptParamAndPlaceholderDto
.
getParam
());
}
List
<
String
>
cmdList
=
Arrays
.
asList
(
command
.
split
(
" "
));
List
<
String
>
cmdList
=
Arrays
.
asList
(
CmdUtil
.
partitionCommandLine
(
command
));
MythJobProcess
mythJobProcess
=
new
MythJobProcess
(
cmdList
,
null
,
null
,
scriptDto
.
getLogId
(),
stringRedisTemplate
);
//保存日志
String
logData
=
mythJobProcess
.
call
();
...
...
byit-myth-executor/myth-executor-server/src/main/java/com/byit/utils/CmdUtil.java
0 → 100644
View file @
787cd9f8
package
com
.
byit
.
utils
;
import
java.util.ArrayList
;
public
class
CmdUtil
{
public
static
String
[]
partitionCommandLine
(
final
String
command
)
{
final
ArrayList
<
String
>
commands
=
new
ArrayList
<>();
int
index
=
0
;
StringBuffer
buffer
=
new
StringBuffer
(
command
.
length
());
boolean
isApos
=
false
;
boolean
isQuote
=
false
;
while
(
index
<
command
.
length
())
{
final
char
c
=
command
.
charAt
(
index
);
switch
(
c
)
{
case
' '
:
if
(!
isQuote
&&
!
isApos
)
{
final
String
arg
=
buffer
.
toString
();
buffer
=
new
StringBuffer
(
command
.
length
()
-
index
);
if
(
arg
.
length
()
>
0
)
{
commands
.
add
(
arg
);
}
}
else
{
buffer
.
append
(
c
);
}
break
;
case
'\''
:
if
(!
isQuote
)
{
isApos
=
!
isApos
;
}
else
{
buffer
.
append
(
c
);
}
break
;
case
'"'
:
if
(!
isApos
)
{
isQuote
=
!
isQuote
;
}
else
{
buffer
.
append
(
c
);
}
break
;
default
:
buffer
.
append
(
c
);
}
index
++;
}
if
(
buffer
.
length
()
>
0
)
{
final
String
arg
=
buffer
.
toString
();
commands
.
add
(
arg
);
}
return
commands
.
toArray
(
new
String
[
commands
.
size
()]);
}
}
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