Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
et-nik committed Jan 17, 2023
2 parents c197cac + 9724b7d commit 50686f7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions internal/app/gdaemon_scheduler/task_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package gdaemonscheduler
import (
"context"
"io"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -199,7 +200,7 @@ func (manager *TaskManager) executeTask(ctx context.Context, task *domain.GDTask
}

func (manager *TaskManager) executeCommand(ctx context.Context, task *domain.GDTask) error {
cmd := newExecuteCommand(manager.executor)
cmd := newExecuteCommand(manager.config, manager.executor)

manager.commandsInProgress.Store(*task, cmd)

Expand Down Expand Up @@ -404,6 +405,7 @@ func (q *taskQueue) Len() int {
}

type executeCommand struct {
config *config.Config
output io.ReadWriter
mu *sync.Mutex
complete bool
Expand All @@ -412,8 +414,9 @@ type executeCommand struct {
executor contracts.Executor
}

func newExecuteCommand(executor contracts.Executor) *executeCommand {
func newExecuteCommand(config *config.Config, executor contracts.Executor) *executeCommand {
return &executeCommand{
config: config,
executor: executor,
output: components.NewSafeBuffer(),
mu: &sync.Mutex{},
Expand All @@ -425,6 +428,9 @@ func (e *executeCommand) Execute(
command string,
options contracts.ExecutorOptions,
) error {
command = strings.ReplaceAll(command, "{node_work_path}", e.config.WorkPath)
command = strings.ReplaceAll(command, "{node_tools_path}", e.config.WorkPath+"/tools")

result, err := e.executor.ExecWithWriter(ctx, command, e.output, options)

e.mu.Lock()
Expand Down

0 comments on commit 50686f7

Please sign in to comment.