Skip to content

Commit

Permalink
Update cmd/main.go with the examplebroker changes
Browse files Browse the repository at this point in the history
Now the daemon executes its own system bus and exports the broker on it.
  • Loading branch information
denisonbarbosa committed Aug 14, 2023
1 parent d2b6008 commit fe7990e
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions cmd/authd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import (
"os/signal"
"sync"
"syscall"
"time"

"github.com/ubuntu/authd/cmd/authd/daemon"
"github.com/ubuntu/authd/internal/brokers/examplebroker"
"github.com/ubuntu/authd/internal/log"
"github.com/ubuntu/authd/internal/testutils"

Check failure on line 15 in cmd/authd/main.go

View workflow job for this annotation

GitHub Actions / Code sanity

no required module provides package github.com/ubuntu/authd/internal/testutils; to add it:

Check failure on line 15 in cmd/authd/main.go

View workflow job for this annotation

GitHub Actions / Code sanity

no required module provides package github.com/ubuntu/authd/internal/testutils; to add it:

Check failure on line 15 in cmd/authd/main.go

View workflow job for this annotation

GitHub Actions / Code sanity

could not import github.com/ubuntu/authd/internal/testutils (invalid package name: "")

Check failure on line 15 in cmd/authd/main.go

View workflow job for this annotation

GitHub Actions / Code sanity

could not import github.com/ubuntu/authd/internal/testutils (invalid package name: "")

Check failure on line 15 in cmd/authd/main.go

View workflow job for this annotation

GitHub Actions / Tests

no required module provides package github.com/ubuntu/authd/internal/testutils; to add it:
)

//FIXME go:generate go run ../generate_completion_documentation.go completion ../../generated
Expand All @@ -19,15 +21,32 @@ import (

func main() {
//i18n.InitI18nDomain(common.TEXTDOMAIN)
cleanup, err := testutils.StartSystemBusMock()
if err != nil {
os.Exit(1)
}

ctx, cancel := context.WithCancel(context.Background())
defer cancel()
done := make(chan struct{})
go func() {
err := examplebroker.StartBus()
if err != nil {
if err = examplebroker.StartBus(ctx); err != nil {
log.Error(context.Background(), err)
cleanup()
os.Exit(1)
}
close(done)
}()
a := daemon.New()
os.Exit(run(a))
// Give some time for the broker to start
time.Sleep(time.Second)

exitCode := run(daemon.New())
// After the daemon has exited, we can stop the broker as well.
cancel()
<-done
// We use os.Exit, so we need to call cleanup manually since defered functions won't be executed.
cleanup()
os.Exit(exitCode)
}

type app interface {
Expand Down

0 comments on commit fe7990e

Please sign in to comment.