diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-03-26 09:09:19 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-03-26 09:14:14 +0000 |
| commit | 3f9843b34d7ae9df2dd9c69427ecab45744b97e9 (patch) | |
| tree | 1c667c17d77b43a1e5fbcae464068a74c2857fb5 /internal/api | |
| parent | dac676e8284725c8ec6de08282fe08a9b519ccc8 (diff) | |
feat: graceful shutdown — drain workers before exit (default 3m timeout)
- 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 <noreply@anthropic.com>
Diffstat (limited to 'internal/api')
| -rw-r--r-- | internal/api/server.go | 3 |
1 files changed, 3 insertions, 0 deletions
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{ |
