Skip to content

Commit

Permalink
feat: enhance task runner with task status updates and process comman…
Browse files Browse the repository at this point in the history
…d 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.
  • Loading branch information
Marvin Zhang committed Jan 3, 2025
1 parent 47094b8 commit a585ab1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions core/task/handler/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion core/utils/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit a585ab1

Please sign in to comment.