aboutsummaryrefslogtreecommitdiff
path: root/internal/exec/tsch/exec.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/exec/tsch/exec.go')
-rw-r--r--internal/exec/tsch/exec.go15
1 files changed, 13 insertions, 2 deletions
diff --git a/internal/exec/tsch/exec.go b/internal/exec/tsch/exec.go
index 1996f27..49a2dc2 100644
--- a/internal/exec/tsch/exec.go
+++ b/internal/exec/tsch/exec.go
@@ -145,10 +145,12 @@ func (mod *Module) Exec(ctx context.Context, ecfg *exec.ExecutionConfig) (err er
} else {
taskPath := cfg.TaskPath
+
if taskPath == "" {
log.Debug().Msg("Task path not defined. Using random path")
taskPath = `\` + util.RandomString()
}
+
st := newSettings(true, true, false)
tk := newTask(st, nil, triggers{}, ecfg.ExecutableName, ecfg.ExecutableArgs)
@@ -157,12 +159,20 @@ func (mod *Module) Exec(ctx context.Context, ecfg *exec.ExecutionConfig) (err er
if err != nil {
return fmt.Errorf("call registerTask: %w", err)
}
+
if !cfg.NoDelete {
defer mod.deleteTask(ctx, taskPath)
}
+
+ var flags uint32
+
+ if cfg.SessionId != 0 {
+ flags |= 4
+ }
_, err := mod.tsch.Run(ctx, &itaskschedulerservice.RunRequest{
- Path: taskPath,
- Flags: 0, // Maybe we want to use these?
+ Path: taskPath,
+ Flags: flags,
+ SessionID: cfg.SessionId,
})
if err != nil {
log.Error().Str("task", taskPath).Err(err).Msg("Failed to run task")
@@ -170,6 +180,7 @@ func (mod *Module) Exec(ctx context.Context, ecfg *exec.ExecutionConfig) (err er
}
log.Info().Str("task", taskPath).Msg("Started task")
}
+
} else {
return fmt.Errorf("method '%s' not implemented", ecfg.ExecutionMethod)
}