Skip to content

Commit

Permalink
feat: node replace arguments & export node special execution log path…
Browse files Browse the repository at this point in the history
… environment
  • Loading branch information
halalala222 committed Aug 16, 2024
1 parent 18ad316 commit 11a0808
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions internal/dag/scheduler/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ import (
"sync"
"time"

"golang.org/x/sys/unix"

"github.com/daguflow/dagu/internal/constants"
"github.com/daguflow/dagu/internal/dag"
"github.com/daguflow/dagu/internal/dag/executor"
"github.com/daguflow/dagu/internal/util"
"golang.org/x/sys/unix"
)

type NodeStatus int
Expand Down Expand Up @@ -154,7 +156,7 @@ func (n *Node) setupExec(ctx context.Context) (executor.Executor, error) {
defer n.mu.Unlock()

ctx, fn := context.WithCancel(ctx)

n.data.Step.NodeID = n.id
n.cancelFunc = fn

if n.data.Step.CmdWithArgs != "" {
Expand Down Expand Up @@ -360,6 +362,12 @@ func (n *Node) setupLog() error {
n.logLock.Lock()
defer n.logLock.Unlock()
var err error
key := util.GenerateStepSpecialExecutionLogPathKey(n.id)
fmt.Printf(key)
if err = os.Setenv(util.GenerateStepSpecialExecutionLogPathKey(n.id), n.data.Log); err != nil {
fmt.Printf("Error setting env: %s", err)
return err
}
n.logFile, err = util.OpenOrCreateFile(n.data.Log)
if err != nil {
n.data.Error = err
Expand Down Expand Up @@ -433,6 +441,13 @@ func (n *Node) init() {
return
}
n.id = getNextNodeID()

n.data.Step.CmdWithArgs = strings.ReplaceAll(
n.data.Step.CmdWithArgs,
constants.StepDaguExecutionLogPathKeySuffix,
util.GenerateStepSpecialExecutionLogPathKey(n.id),
)

if n.data.Step.Variables == nil {
n.data.Step.Variables = []string{}
}
Expand Down

0 comments on commit 11a0808

Please sign in to comment.