Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move render events to after template command #1370

Merged
merged 2 commits into from
Apr 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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