[ Agent ] [ Executor ] - fix bugs
This commit is contained in:
@@ -12,7 +12,7 @@ import (
|
||||
type ExecutionMessage struct {
|
||||
NeedResultReplay bool `json:"needResultReplay"`
|
||||
DurationTask bool `json:"durationTask,default:false"`
|
||||
Type string `json:"type"`
|
||||
ExecutionType string `json:"executionType"`
|
||||
FuncContent []string `json:"funcContent"`
|
||||
SingleLineCommand []string `json:"singleLineCommand"`
|
||||
MultiLineCommand [][]string `json:"multiLineCommand"`
|
||||
@@ -31,7 +31,9 @@ func Execute(em *ExecutionMessage) ([]string, error) {
|
||||
var realCommand [][]string
|
||||
ok := true
|
||||
|
||||
if strings.HasPrefix(em.Type, "BASE") {
|
||||
log.DebugF("em message is => %#v", em)
|
||||
|
||||
if strings.HasPrefix(em.ExecutionType, "BASE") {
|
||||
// base function
|
||||
if len(em.FuncContent) > 1 {
|
||||
ok, resultLog = AgentOsOperatorCache.Exec(em.FuncContent[0], em.FuncContent[1:]...)
|
||||
@@ -42,7 +44,7 @@ func Execute(em *ExecutionMessage) ([]string, error) {
|
||||
return resultLog, nil
|
||||
}
|
||||
|
||||
} else if strings.HasPrefix(em.Type, "APP") {
|
||||
} else if strings.HasPrefix(em.ExecutionType, "APP") {
|
||||
// app function
|
||||
if len(em.FuncContent) > 1 {
|
||||
ok, resultLog = AgentOsOperatorCache.Deploy(em.FuncContent[0], em.FuncContent[1:]...)
|
||||
@@ -57,7 +59,6 @@ func Execute(em *ExecutionMessage) ([]string, error) {
|
||||
|
||||
} else {
|
||||
// shell command
|
||||
|
||||
if em.PipeLineCommand != nil && len(em.PipeLineCommand) != 0 {
|
||||
// 管道命令
|
||||
resultLog, err = PipeLineCommandExecutor(em.PipeLineCommand)
|
||||
|
||||
@@ -70,8 +70,13 @@ func FormatAllCommandExecutor(singleLineCommand []string) ([]string, error) {
|
||||
// result
|
||||
var resultSlice []string
|
||||
var resultError error
|
||||
var cmd *exec.Cmd
|
||||
|
||||
cmd := exec.Command(singleLineCommand[0], singleLineCommand[1:]...)
|
||||
if len(singleLineCommand) > 1 {
|
||||
cmd = exec.Command(singleLineCommand[0], singleLineCommand[1:]...)
|
||||
} else {
|
||||
cmd = exec.Command(singleLineCommand[0])
|
||||
}
|
||||
stdout, err := cmd.StdoutPipe()
|
||||
if err != nil {
|
||||
log.ErrorF("command %v stdout error => %v", singleLineCommand, err)
|
||||
|
||||
@@ -277,9 +277,12 @@ CheckAndDownloadLatestVersion() {
|
||||
echo ""
|
||||
|
||||
colorEcho $BLUE "start to download the agent config!"
|
||||
agentConfigFileList=$(curl "$AgentConfigUrl/" | grep -v h1 | grep "a href=" | awk '{print$2}' | cut -d">" -f2 | cut -d"<" -f1 | cut -d"_" -f4-)
|
||||
rm -rf index.html
|
||||
agentConfigFileList=$(curl "$AgentConfigUrl/" | grep -v h1 | grep "a href=" | awk '{print$2}' | cut -d">" -f2 | cut -d"<" -f1 | cut -d"_" -f4- | tr "\n" " ")
|
||||
|
||||
for agentConfig in "${agentConfigFileList[@]}"; do
|
||||
IFS=" " read -ra file_array <<<"$agentConfigFileList"
|
||||
|
||||
for agentConfig in "${file_array[@]}"; do
|
||||
colorEcho $BLUE "agent config file is => $agentConfig"
|
||||
wget -q "$AgentConfigUrl/$agentConfig"
|
||||
echo ""
|
||||
|
||||
Reference in New Issue
Block a user