From 66f9a92592c8b82fcf2cfd55c32be517504f15e15c26ffc86d0799f33ef25b5e Mon Sep 17 00:00:00 2001 From: Lixen Wraith Date: Fri, 11 Jul 2025 21:47:22 -0400 Subject: [PATCH] v0.2.2 minor fixes --- src/internal/config/logging.go | 5 ----- src/internal/service/pipeline.go | 2 +- src/internal/service/service.go | 12 +++++++++++- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/internal/config/logging.go b/src/internal/config/logging.go index d237725..b9ad127 100644 --- a/src/internal/config/logging.go +++ b/src/internal/config/logging.go @@ -87,11 +87,6 @@ func validateLogConfig(cfg *LogConfig) error { return fmt.Errorf("invalid console target: %s", cfg.Console.Target) } - // TODO: check if file output check is correct - if cfg.Console.Target == "split" && cfg.Output == "file" { - return fmt.Errorf("console target 'split' requires output mode 'stdout', 'stderr', or 'both'") - } - validFormats := map[string]bool{ "txt": true, "json": true, "": true, } diff --git a/src/internal/service/pipeline.go b/src/internal/service/pipeline.go index 67ae39e..3ac45b3 100644 --- a/src/internal/service/pipeline.go +++ b/src/internal/service/pipeline.go @@ -85,7 +85,7 @@ func (p *Pipeline) Shutdown() { // GetStats returns pipeline statistics func (p *Pipeline) GetStats() map[string]any { // Recovery to handle concurrent access during shutdown - // TODO: check if needed to keep + // When service is shutting down, sources/sinks might be nil or partially stopped defer func() { if r := recover(); r != nil { p.logger.Error("msg", "Panic getting pipeline stats", diff --git a/src/internal/service/service.go b/src/internal/service/service.go index 2ae3499..e084579 100644 --- a/src/internal/service/service.go +++ b/src/internal/service/service.go @@ -144,13 +144,23 @@ func (s *Service) wirePipeline(p *Pipeline) { defer p.wg.Done() // Panic recovery to prevent single source from crashing pipeline - // TODO: check if failed pipeline is properly shut down defer func() { if r := recover(); r != nil { s.logger.Error("msg", "Panic in pipeline processing", "pipeline", p.Name, "source", source.GetStats().Type, "panic", r) + + // Ensure failed pipelines don't leave resources hanging + go func() { + s.logger.Warn("msg", "Shutting down pipeline due to panic", + "pipeline", p.Name) + if err := s.RemovePipeline(p.Name); err != nil { + s.logger.Error("msg", "Failed to remove panicked pipeline", + "pipeline", p.Name, + "error", err) + } + }() } }()