diff --git a/contract.go b/contract.go index 57d542a..7d65926 100644 --- a/contract.go +++ b/contract.go @@ -169,15 +169,7 @@ func WithService(factory func(*Core) Result) CoreOption { return Result{E("core.WithService", Sprintf("service name could not be discovered for type %T", instance), nil), false} } - // IPC handler discovery - instanceValue := reflect.ValueOf(instance) - handlerMethod := instanceValue.MethodByName("HandleIPCEvents") - if handlerMethod.IsValid() { - if handler, ok := handlerMethod.Interface().(func(*Core, Message) Result); ok { - c.RegisterAction(handler) - } - } - + // RegisterService handles Startable/Stoppable/HandleIPCEvents discovery return c.RegisterService(name, instance) } } diff --git a/core.go b/core.go index 70b3378..9074b5c 100644 --- a/core.go +++ b/core.go @@ -80,7 +80,7 @@ func (c *Core) Run() { r = cli.Run() } - c.ServiceShutdown(c.context) + c.ServiceShutdown(context.Background()) if !r.OK { if err, ok := r.Value.(error); ok { diff --git a/service.go b/service.go index 20e2419..14324db 100644 --- a/service.go +++ b/service.go @@ -17,6 +17,8 @@ package core +import "context" + // Service is a managed component with optional lifecycle. type Service struct { Name string @@ -109,7 +111,7 @@ func (c *Core) RegisterService(name string, instance any) Result { } if s, ok := instance.(Stoppable); ok { srv.OnStop = func() Result { - if err := s.OnShutdown(c.context); err != nil { + if err := s.OnShutdown(context.Background()); err != nil { return Result{err, false} } return Result{OK: true}