Skip to content

[log] Add debug logging to HTTP server lifecycle in serve.go#7123

Merged
lpcox merged 2 commits into
mainfrom
log/enhance-serve-029c5df7ac68ec64
Jun 7, 2026
Merged

[log] Add debug logging to HTTP server lifecycle in serve.go#7123
lpcox merged 2 commits into
mainfrom
log/enhance-serve-029c5df7ac68ec64

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented Jun 6, 2026

Adds 5 meaningful debugLog calls to serveAndWait in internal/cmd/serve.go, covering key HTTP server lifecycle events:

Log call Event
Starting HTTP server: addr=%s, shutdownTimeout=%s Function entry — server address and timeout
HTTP server exited unexpectedly, triggering shutdown: %v Unexpected exit from serveFn before context is cancelled
Shutdown signal received, beginning graceful HTTP server shutdown Context cancellation — graceful shutdown begins
Graceful shutdown failed, forcing close: %v httpServer.Shutdown() returned an error
HTTP server shut down gracefully Clean graceful shutdown path

Why this file?

serveAndWait is the core server lifecycle helper called from root.go for every gateway startup. It orchestrates background serving, signal handling, graceful shutdown, and error propagation — but had zero debug visibility. These logs help diagnose startup failures and shutdown timing issues.

Implementation notes

  • Reuses the existing package-level debugLog = logger.New("cmd:root") declared in root.go — no new logger or import needed
  • No side effects in log arguments (only uses already-computed values httpServer.Addr, timeout, err)
  • All tests pass (make test-all green; Rust guard failure is a pre-existing network sandbox limitation)

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • index.crates.io

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "index.crates.io"

See Network Configuration for more information.

Generated by Go Logger Enhancement · sonnet46 8.3M ·

Add 5 meaningful debug log calls to the serveAndWait function using
the existing package-level debugLog logger. These log server startup,
unexpected exits, shutdown signal receipt, graceful shutdown failures,
and successful graceful shutdown — all key lifecycle events that aid
in troubleshooting server startup and shutdown behaviour.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added automation enhancement New feature or request labels Jun 6, 2026
@lpcox lpcox marked this pull request as ready for review June 7, 2026 16:51
Copilot AI review requested due to automatic review settings June 7, 2026 16:51
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves debuggability of the gateway’s HTTP server lifecycle by adding debugLog statements to serveAndWait (internal/cmd/serve.go), which is used as the shared serve/shutdown helper for gateway startup and proxy mode.

Changes:

  • Add a debug log at serveAndWait entry with server address and shutdown timeout.
  • Add debug logs for unexpected server exit (triggering cancellation) and for the shutdown path (start, shutdown failure with forced close, graceful completion).
Show a summary per file
File Description
internal/cmd/serve.go Adds debug-level visibility into core HTTP server start/stop lifecycle within serveAndWait.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/1 changed files
  • Comments generated: 1

Comment thread internal/cmd/serve.go Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@lpcox lpcox merged commit 9c9df3f into main Jun 7, 2026
16 checks passed
@lpcox lpcox deleted the log/enhance-serve-029c5df7ac68ec64 branch June 7, 2026 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants