From 5ed944dfc3e82cc837ee4043f18877c3172b269c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Wed, 17 Dec 2025 18:16:11 +0100 Subject: [PATCH] fix service name in suture logs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- opencloud/pkg/runtime/service/service.go | 4 ++-- opencloud/pkg/runtime/service/sutureservice.go | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/opencloud/pkg/runtime/service/service.go b/opencloud/pkg/runtime/service/service.go index a02bab58c..440487052 100644 --- a/opencloud/pkg/runtime/service/service.go +++ b/opencloud/pkg/runtime/service/service.go @@ -124,7 +124,7 @@ func NewService(ctx context.Context, options ...Option) (*Service, error) { if s.Services[priority] == nil { s.Services[priority] = make(serviceFuncMap) } - s.Services[priority][name] = NewSutureServiceBuilder(exec) + s.Services[priority][name] = NewSutureServiceBuilder(name, exec) } // nats is in priority group 0. It needs to start before all other services @@ -316,7 +316,7 @@ func NewService(ctx context.Context, options ...Option) (*Service, error) { // populate optional services areg := func(name string, exec func(context.Context, *occfg.Config) error) { - s.Additional[name] = NewSutureServiceBuilder(exec) + s.Additional[name] = NewSutureServiceBuilder(name, exec) } areg(opts.Config.Antivirus.Service.Name, func(ctx context.Context, cfg *occfg.Config) error { cfg.Antivirus.Context = ctx diff --git a/opencloud/pkg/runtime/service/sutureservice.go b/opencloud/pkg/runtime/service/sutureservice.go index 2a5456687..c23da5f61 100644 --- a/opencloud/pkg/runtime/service/sutureservice.go +++ b/opencloud/pkg/runtime/service/sutureservice.go @@ -10,15 +10,17 @@ import ( // SutureService allows for the settings command to be embedded and supervised by a suture supervisor tree. type SutureService struct { exec func(ctx context.Context) error + name string } // NewSutureServiceBuilder creates a new suture service -func NewSutureServiceBuilder(f func(context.Context, *occfg.Config) error) func(*occfg.Config) suture.Service { +func NewSutureServiceBuilder(name string, f func(context.Context, *occfg.Config) error) func(*occfg.Config) suture.Service { return func(cfg *occfg.Config) suture.Service { return SutureService{ exec: func(ctx context.Context) error { return f(ctx, cfg) }, + name: name, } } } @@ -27,3 +29,8 @@ func NewSutureServiceBuilder(f func(context.Context, *occfg.Config) error) func( func (s SutureService) Serve(ctx context.Context) error { return s.exec(ctx) } + +// String to fullfil fmt.Stringer interface, used to log the service name +func (s SutureService) String() string { + return s.name +}