mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-04-30 15:59:55 -05:00
fix service name in suture logs
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
This commit is contained in:
committed by
Ralf Haferkamp
parent
a7defc2d70
commit
5ed944dfc3
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user