Skip to content

feat: log shutdown signal cause#83

Merged
raeperd merged 1 commit into
mainfrom
feat/log-shutdown-cause
Apr 10, 2026
Merged

feat: log shutdown signal cause#83
raeperd merged 1 commit into
mainfrom
feat/log-shutdown-cause

Conversation

@raeperd
Copy link
Copy Markdown
Owner

@raeperd raeperd commented Apr 10, 2026

Summary

  • Log which OS signal (SIGINT/SIGTERM) caused the server shutdown by adding context.Cause(ctx) to the shutdown log line
  • Uses Go 1.26's signal.NotifyContext cancel cause, which automatically sets the context cause to the received signal

Test plan

  • make test passes (all existing tests green)
  • make lint passes (0 issues)
  • Manual: run server, send SIGINT (Ctrl-C), verify log includes "cause":"signal: interrupt"
  • Manual: run server, send SIGTERM, verify log includes "cause":"signal: terminated"

Summary by CodeRabbit

  • Chores
    • Enhanced server shutdown logging to include additional contextual details during server termination.

Use context.Cause(ctx) to include the OS signal that triggered
shutdown (SIGINT/SIGTERM) in the log message.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 10, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8a0f5c49-3045-44b5-8808-0a34df52d0a2

📥 Commits

Reviewing files that changed from the base of the PR and between d7a3afa and 7449573.

📒 Files selected for processing (1)
  • main.go

📝 Walkthrough

Walkthrough

A single-line modification to main.go enhances the server shutdown logging by adding a structured field that captures the context cancellation reason using context.Cause(ctx), providing additional diagnostic information without altering shutdown behavior.

Changes

Cohort / File(s) Summary
Shutdown Logging Enhancement
main.go
Added slog.Any("cause", context.Cause(ctx)) field to capture the shutdown reason in the server shutdown log message.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐰 A carrot of cause, now logged with care,
When servers must shutdown mid-air,
We'll know the "why" with structured delight,
Context revealed in logs so bright! 🌟

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: log shutdown signal cause' accurately describes the main change: adding structured logging of the shutdown signal cause via context.Cause(ctx).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/log-shutdown-cause

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coveralls
Copy link
Copy Markdown

Coverage Status

coverage: 79.739%. remained the same — feat/log-shutdown-cause into main

@raeperd raeperd merged commit 4eb0324 into main Apr 10, 2026
5 checks passed
@raeperd raeperd deleted the feat/log-shutdown-cause branch April 10, 2026 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants