fix: add init to services and node

This commit is contained in:
Derrick Hammer 2024-01-30 15:46:00 -05:00
parent 8914bada60
commit 9919ad72da
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
3 changed files with 16 additions and 0 deletions

View File

@ -55,6 +55,10 @@ func (n *Node) Start() error {
return n.services.Start() return n.services.Start()
} }
func (n *Node) Init() error {
return n.services.Init()
}
func (n *Node) Stop() error { func (n *Node) Stop() error {
return n.services.Stop() return n.services.Stop()
} }

View File

@ -69,6 +69,17 @@ func (s *ServicesImpl) IsStarted() bool {
return s.started return s.started
} }
func (s *ServicesImpl) Init() error {
for _, svc := range s.All() {
err := svc.Init()
if err != nil {
return err
}
}
return nil
}
func (s *ServicesImpl) Start() error { func (s *ServicesImpl) Start() error {
for _, svc := range s.All() { for _, svc := range s.All() {
err := svc.Start() err := svc.Start()

View File

@ -21,6 +21,7 @@ type Services interface {
HTTP() HTTPService HTTP() HTTPService
Storage() StorageService Storage() StorageService
All() []Service All() []Service
Init() error
IsStarted() bool IsStarted() bool
Start() error Start() error
Stop() error Stop() error