From 3f9843b34d7ae9df2dd9c69427ecab45744b97e9 Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Thu, 26 Mar 2026 09:09:19 +0000 Subject: feat: graceful shutdown — drain workers before exit (default 3m timeout) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add workerWg to Pool; Shutdown() closes workCh and waits for all in-flight execute/executeResume goroutines to finish - Signal handler now shuts down HTTP first, then drains the pool - ShutdownTimeout config field (toml: shutdown_timeout); default 3m - Tests: WaitsForWorkers and TimesOut Co-Authored-By: Claude Sonnet 4.6 --- internal/api/server.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'internal/api') diff --git a/internal/api/server.go b/internal/api/server.go index 8eba829..be944a3 100644 --- a/internal/api/server.go +++ b/internal/api/server.go @@ -79,6 +79,9 @@ func (s *Server) SetWorkspaceRoot(path string) { s.workspaceRoot = path } +// Pool returns the executor pool, for graceful shutdown by the caller. +func (s *Server) Pool() *executor.Pool { return s.pool } + func NewServer(store *storage.DB, pool *executor.Pool, logger *slog.Logger, claudeBinPath, geminiBinPath string) *Server { wd, _ := os.Getwd() s := &Server{ -- cgit v1.2.3