Remove more os.Exit calls and give a more reliable wait for stop function

This commit is contained in:
Nate Brown
2025-04-02 09:51:59 -05:00
parent 01909f4715
commit c3ec96d9c2
6 changed files with 109 additions and 32 deletions

View File

@@ -44,7 +44,10 @@ type Service struct {
}
func New(control *nebula.Control) (*Service, error) {
control.Start()
wait, err := control.Start()
if err != nil {
return nil, err
}
ctx := control.Context()
eg, ctx := errgroup.WithContext(ctx)
@@ -141,6 +144,12 @@ func New(control *nebula.Control) (*Service, error) {
}
})
// Add the nebula wait function to the group
eg.Go(func() error {
wait()
return nil
})
return &s, nil
}