Skip to content

Commit

Permalink
Merge pull request #1370 from hashicorp/issue-1369-event-command-race
Browse files Browse the repository at this point in the history
move render events to after template command
  • Loading branch information
eikenb authored Apr 23, 2020
2 parents ba7887c + 7a1c3e4 commit 942a131
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,9 @@ template {
command = "restart service foo"
# This is the maximum amount of time to wait for the optional command to
# return. Default is 30s.
# return. If you set the timeout to 0s the command is run in the background
# without monitoring it for errors. If also using Once, consul-template can
# exit before the command is finished. Default is 30s.
command_timeout = "60s"
# Exit with an error when accessing a struct or map field/key that does not
Expand Down
34 changes: 17 additions & 17 deletions manager/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,23 +556,6 @@ func (r *Runner) Run() error {
}
}

// Check if we need to deliver any rendered signals
if wouldRenderAny || renderedAny {
// Send the signal that a template got rendered
select {
case r.renderedCh <- struct{}{}:
default:
}
}

// Check if we need to deliver any event signals
if newRenderEvent {
select {
case r.renderEventCh <- struct{}{}:
default:
}
}

// Perform the diff and update the known dependencies.
r.diffAndUpdateDeps(runCtx.depsMap)

Expand Down Expand Up @@ -601,6 +584,23 @@ func (r *Runner) Run() error {
}
}

// Check if we need to deliver any rendered signals
if wouldRenderAny || renderedAny {
// Send the signal that a template got rendered
select {
case r.renderedCh <- struct{}{}:
default:
}
}

// Check if we need to deliver any event signals
if newRenderEvent {
select {
case r.renderEventCh <- struct{}{}:
default:
}
}

// If we got this far and have a child process, we need to send the reload
// signal to the child process.
if renderedAny && r.child != nil {
Expand Down

0 comments on commit 942a131

Please sign in to comment.