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 f5d096dd2b
commit c9ff55d586
6 changed files with 109 additions and 31 deletions

View File

@@ -54,7 +54,11 @@ func New(config *config.C) (*Service, error) {
if err != nil {
return nil, err
}
control.Start()
wait, err := control.Start()
if err != nil {
return nil, err
}
ctx := control.Context()
eg, ctx := errgroup.WithContext(ctx)
@@ -151,6 +155,12 @@ func New(config *config.C) (*Service, error) {
}
})
// Add the nebula wait function to the group
eg.Go(func() error {
wait()
return nil
})
return &s, nil
}