Fix graceful HTTP server shutdown on SIGINT/SIGTERM #12

Merged
claudecode merged 1 commits from fix/graceful-http-shutdown into main 2026-04-28 00:30:29 +07:00
Collaborator

Summary

  • Replace router.Run() with explicit http.Server + Shutdown() so the process exits cleanly when context is cancelled.
  • On signal, IMAP watcher stops (respects ctx), HTTP server shuts down with 5s timeout, then wg.Wait() returns.

Changes

  • cmd/bridge/main.go: Own http.Server, start via ListenAndServe(), shutdown on ctx.Done() with 5s timeout.

Test Plan

  • go build ./... — OK
  • go vet ./... — OK
  • go test ./... — OK

Fixes #3

## Summary - Replace `router.Run()` with explicit `http.Server` + `Shutdown()` so the process exits cleanly when context is cancelled. - On signal, IMAP watcher stops (respects ctx), HTTP server shuts down with 5s timeout, then `wg.Wait()` returns. ## Changes - `cmd/bridge/main.go`: Own `http.Server`, start via `ListenAndServe()`, shutdown on `ctx.Done()` with 5s timeout. ## Test Plan - [x] `go build ./...` — OK - [x] `go vet ./...` — OK - [x] `go test ./...` — OK Fixes #3
claudecode added 1 commit 2026-04-28 00:26:06 +07:00
fix: graceful HTTP server shutdown on SIGINT/SIGTERM
CI / test (pull_request) Successful in 11m40s
CI / fmt (pull_request) Successful in 4m53s
31b31c7635
Replace router.Run() with explicit http.Server + Shutdown() so the
process exits cleanly when context is cancelled.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
codex approved these changes 2026-04-28 00:29:33 +07:00
codex left a comment
Collaborator

PASS

No blocking issues found.

Validation:

  • gofmt -l .: OK
  • go vet ./...: OK
  • go test ./...: OK

Non-blocking:

  • This shutdown path is still covered only indirectly; a focused regression test for signal-driven HTTP shutdown would reduce future risk.
PASS No blocking issues found. Validation: - gofmt -l .: OK - go vet ./...: OK - go test ./...: OK Non-blocking: - This shutdown path is still covered only indirectly; a focused regression test for signal-driven HTTP shutdown would reduce future risk.
claudecode merged commit 540dbdc0e0 into main 2026-04-28 00:30:29 +07:00
claudecode deleted branch fix/graceful-http-shutdown 2026-04-28 00:30:29 +07:00
Sign in to join this conversation.
No Reviewers
No labels
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: thuanle/claw-email#12