Skip to content

Commit

Permalink
only wait for unblock if template server is initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
catsby committed Oct 17, 2019
1 parent 288c4a7 commit 419f21b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions command/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ func (c *AgentCommand) Run(args []string) int {
// TODO: implement support for SIGHUP reloading of configuration
// signal.Notify(c.signalCh)

var ssDoneCh, ahDoneCh, tsDoneCh chan struct{}
var ssDoneCh, ahDoneCh, tsDoneCh, unblockCh chan struct{}
var ts *template.Server
// Start auto-auth and sink servers
if method != nil {
Expand Down Expand Up @@ -529,6 +529,7 @@ func (c *AgentCommand) Run(args []string) int {
ExitAfterAuth: config.ExitAfterAuth,
})
tsDoneCh = ts.DoneCh
unblockCh = ts.UnblockCh

go ah.Run(ctx, method)
go ss.Run(ctx, ah.OutputCh, sinks)
Expand Down Expand Up @@ -563,10 +564,13 @@ func (c *AgentCommand) Run(args []string) int {
}
}()

// Wait for the template to render
select {
case <-ctx.Done():
case <-ts.UnblockCh:
// If the template server is running and we've assinged the Unblock channel,
// wait for the template to render
if unblockCh != nil {
select {
case <-ctx.Done():
case <-ts.UnblockCh:
}
}

select {
Expand Down

0 comments on commit 419f21b

Please sign in to comment.