summaryrefslogtreecommitdiff
path: root/internal/server/handlers/basehandler.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-06-30 23:58:30 +0300
committerPaul Buetow <paul@buetow.org>2025-06-30 23:58:30 +0300
commita3f6bb625aad2cd4a0c86af44feaa22aa401331f (patch)
tree79878744944bebf5a4346ca0bff338be83a20f23 /internal/server/handlers/basehandler.go
parent7a917e6e81bf8e956eff2a4a54e9300ab2747949 (diff)
feat: track pending files to prevent premature server shutdown
- Add pendingFiles counter to ServerHandler to track files waiting for limiter slots - Only shutdown when both activeCommands and pendingFiles are zero - Increment pendingFiles when starting to process a batch of files - Decrement as each file completes processing - Add comprehensive logging for debugging shutdown issues - Flush turbo data before signaling EOF to ensure all data is transmitted This fixes the issue where the server would shutdown while files were still queued in the catLimiter, causing incomplete processing when MaxConcurrentCats is lower than the number of files being processed. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'internal/server/handlers/basehandler.go')
-rw-r--r--internal/server/handlers/basehandler.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/internal/server/handlers/basehandler.go b/internal/server/handlers/basehandler.go
index a82c91a..bfc7ec2 100644
--- a/internal/server/handlers/basehandler.go
+++ b/internal/server/handlers/basehandler.go
@@ -385,7 +385,15 @@ func (h *baseHandler) flush() {
}
func (h *baseHandler) shutdown() {
- dlog.Server.Debug(h.user, "shutdown()")
+ // Log current state at shutdown
+ activeCommands := atomic.LoadInt32(&h.activeCommands)
+ dlog.Server.Info(h.user, "shutdown() called", "activeCommands", activeCommands, "turboMode", h.turboMode)
+
+ // In turbo mode, ensure all data is flushed before shutdown
+ if h.turboMode {
+ h.flushTurboData()
+ }
+
h.flush()
go func() {