Skip to content

Commit

Permalink
Force controller & watcher goroutine to start "early"
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Demeester <[email protected]>
  • Loading branch information
vdemeester authored and Shivam Mukhade committed Jan 5, 2023
1 parent 779a4fa commit 3d0c2ad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/pipelines-as-code-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,15 @@ func main() {
log.Fatal("failed to init kinit client : ", err)
}

c := make(chan struct{})
go func() {
c <- struct{}{}
if err := run.WatchConfigMapChanges(ctx, run); err != nil {
log.Fatal(err)
}
}()
// Force WatchConfigMapChanges go routines to actually start
<-c

evadapter.MainWithContext(ctx, PACControllerLogKey, adapter.NewEnvConfig, adapter.New(run, kinteract))
}
4 changes: 4 additions & 0 deletions cmd/pipelines-as-code-watcher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ func main() {
w.WriteHeader(200)
_, _ = fmt.Fprint(w, "ok")
})

c := make(chan struct{})
go func() {
c <- struct{}{}
// start the web server on port and accept requests
log.Printf("Readiness and health check server listening on port %s", probesPort)
// timeout values same as default one from triggers eventlistener
Expand All @@ -38,6 +41,7 @@ func main() {
}
log.Fatal(srv.ListenAndServe())
}()
<-c

sharedmain.Main("pac-watcher", reconciler.NewController())
}

0 comments on commit 3d0c2ad

Please sign in to comment.