From a585ab16f7c8336f9e7964dbb925be91968ff807 Mon Sep 17 00:00:00 2001 From: Marvin Zhang Date: Fri, 3 Jan 2025 16:44:38 +0800 Subject: [PATCH] feat: enhance task runner with task status updates and process command execution - Added a task status update to 'processing' at the start of the Run method in runner.go, improving task tracking. - Removed redundant task status update from the end of the Run method to streamline the execution flow. - Updated command execution in process.go to use 'bash' instead of 'sh' for better compatibility across environments. --- core/task/handler/runner.go | 10 +++++----- core/utils/process.go | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/task/handler/runner.go b/core/task/handler/runner.go index f0e5a9e4..d0493742 100644 --- a/core/task/handler/runner.go +++ b/core/task/handler/runner.go @@ -148,6 +148,11 @@ func (r *Runner) Run() (err error) { // log task started r.Infof("task[%s] started", r.tid.Hex()) + // update task status (processing) + if err := r.updateTask(constants.TaskStatusRunning, nil); err != nil { + return err + } + // configure working directory r.configureCwd() @@ -184,11 +189,6 @@ func (r *Runner) Run() (err error) { r.pid = r.cmd.Process.Pid r.t.Pid = r.pid - // update task status (processing) - if err := r.updateTask(constants.TaskStatusRunning, nil); err != nil { - return err - } - // start health check go r.startHealthCheck() diff --git a/core/utils/process.go b/core/utils/process.go index 6667aa95..6e0dccd1 100644 --- a/core/utils/process.go +++ b/core/utils/process.go @@ -16,7 +16,7 @@ func BuildCmd(cmdStr string) (cmd *exec.Cmd, err error) { if runtime.GOOS == "windows" { return exec.Command("cmd", "/C", cmdStr), nil } - return exec.Command("sh", "-c", cmdStr), nil + return exec.Command("bash", "-c", cmdStr), nil } func ProcessIdExists(pid int) (exists bool) {