fix: stop the access log watcher when Charon shuts down

Đang mở
#2,138 0 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@Wikid82 đang làm issue này rồi.

Từ ngày 3/12/2026.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
76/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
go
Lĩnh vực
backend

Hướng nghiên cứu

Read backend/internal/services/log_watcher.go and the watcher setup in backend/internal/api/routes/routes.go; compare how the stats ingester and hub receive the application context. Start by tracing LogWatcher.Start(ctx) and its tail loop. Add a test that cancellation stops the loop, then verify the watcher shuts down with server.Run(ctx) and releases its resources.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

backend low

What

The access log watcher keeps running until the process exits instead of stopping with the application context.

  • backend/internal/api/routes/routes.go (log watcher block, logWatcher.Start(context.Background())) starts it with a background context, and nothing calls LogWatcher.Stop() at shutdown.
  • LogWatcher.Start(ctx) (backend/internal/services/log_watcher.go:45) ignores its ctx argument; the tail loop watches the watcher's own context created in NewLogWatcher (:34-42).

CLAUDE.md asks long-running work to respect server.Run(ctx).

Severity

Low. The process exits at shutdown anyway; the gap is an unclean stop (open file handle, subscriber channels left open) and a pattern that differs from the stats ingester and hub, which take ctx.

Suggested approach

Have Start derive the tail loop's context from its ctx argument (or call Stop from context.AfterFunc(ctx, ...)), pass the application context from RegisterWithDeps, and add a test that the tail loop ends when the context is cancelled.

Found while planning #2132.

Ngôn ngữ chính
Go
Star
17
Fork
2
Merge trung bình
1 giờ 42 phút
Pull request đã merge (30 ngày)
173

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Wikid82/Charon

Tất cả issue của Wikid82/Charon

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.