From bda4be17ade25164acd3ab26b15f8fdaaac4c59b Mon Sep 17 00:00:00 2001 From: Jesse Chen Date: Tue, 5 May 2026 16:47:31 -0700 Subject: [PATCH] go executor: restart KeepAlive tasks on clean exit A KeepAlive task that exits with no error and no context cancellation (e.g. an fx service that catches SIGTERM and shuts down gracefully) was treated as "done" and never restarted. This treats it as an error so the existing KeepAlive restart path kicks in. Co-Authored-By: Claude Opus 4.6 (1M context) --- executor.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/executor.go b/executor.go index 4d30a44..a583a89 100644 --- a/executor.go +++ b/executor.go @@ -660,6 +660,14 @@ func (e *Executor) runPass() { simpleEvent: execution.simpleEvent(), Error: err, }) + } else if task.KeepAlive { + // A KeepAlive task should never exit cleanly on its own — + // treat it as an error so it gets restarted. + execution.state = taskExecutionState_error + e.publishEvent(&TaskFailedEvent{ + simpleEvent: execution.simpleEvent(), + Error: fmt.Errorf("keep-alive task %s exited unexpectedly", task.Name), + }) } else { execution.state = taskExecutionState_done e.publishEvent(&TaskCompletedEvent{