feat(process): forward task run options

This commit is contained in:
Virgil 2026-04-03 23:50:52 +00:00
parent 1b7431e3a0
commit 252f68db64
3 changed files with 36 additions and 4 deletions

View file

@ -11,6 +11,16 @@ type TaskProcessRun struct {
Args []string
Dir string
Env []string
// DisableCapture skips buffering process output before returning it.
DisableCapture bool
// Detach runs the command in its own process group.
Detach bool
// Timeout bounds the execution duration.
Timeout time.Duration
// GracePeriod controls SIGTERM-to-SIGKILL escalation.
GracePeriod time.Duration
// KillGroup terminates the entire process group instead of only the leader.
KillGroup bool
}
// ActionProcessStarted is broadcast when a process begins execution.

View file

@ -417,10 +417,15 @@ func (s *Service) handleTask(c *core.Core, task core.Task) core.Result {
switch m := task.(type) {
case TaskProcessRun:
output, err := s.RunWithOptions(c.Context(), RunOptions{
Command: m.Command,
Args: m.Args,
Dir: m.Dir,
Env: m.Env,
Command: m.Command,
Args: m.Args,
Dir: m.Dir,
Env: m.Env,
DisableCapture: m.DisableCapture,
Detach: m.Detach,
Timeout: m.Timeout,
GracePeriod: m.GracePeriod,
KillGroup: m.KillGroup,
})
if err != nil {
return core.Result{Value: err, OK: false}

View file

@ -500,6 +500,23 @@ func TestService_OnStartup(t *testing.T) {
require.True(t, result.OK)
assert.Contains(t, result.Value.(string), "action-run")
})
t.Run("forwards task execution options", func(t *testing.T) {
svc, c := newTestService(t)
err := svc.OnStartup(context.Background())
require.NoError(t, err)
result := c.PERFORM(TaskProcessRun{
Command: "sleep",
Args: []string{"60"},
Timeout: 100 * time.Millisecond,
GracePeriod: 50 * time.Millisecond,
})
require.False(t, result.OK)
assert.Nil(t, result.Value)
})
}
func TestService_RunWithOptions(t *testing.T) {