From 252f68db64bbb589900802c079187c66e9b5f332 Mon Sep 17 00:00:00 2001 From: Virgil Date: Fri, 3 Apr 2026 23:50:52 +0000 Subject: [PATCH] feat(process): forward task run options --- actions.go | 10 ++++++++++ service.go | 13 +++++++++---- service_test.go | 17 +++++++++++++++++ 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/actions.go b/actions.go index a09e520..a93c9db 100644 --- a/actions.go +++ b/actions.go @@ -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. diff --git a/service.go b/service.go index 10d086d..9a5c211 100644 --- a/service.go +++ b/service.go @@ -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} diff --git a/service_test.go b/service_test.go index f0aeff1..e7b8323 100644 --- a/service_test.go +++ b/service_test.go @@ -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) {