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

#templateChanged helper method #7644

Closed
jsirex opened this issue Apr 27, 2020 · 3 comments
Closed

#templateChanged helper method #7644

jsirex opened this issue Apr 27, 2020 · 3 comments
Labels
Focus:Supervisor Related to the Habitat Supervisor (core/hab-sup) component Focus :Templating Improvements or bugs related to templated content in the Supervisor Stale Type: Feature Issues that describe a new desired feature

Comments

@jsirex
Copy link
Contributor

jsirex commented Apr 27, 2020

While it is possible to play with sha256sum in the run hook, validate checksum in the reconfigure hook and do some action it will really handy to have such helper.

Here is example:

# reconfigure
NETWORK_CHANGED='{{#templateChanged "config/network.conf"}}'
MAIN_CHANGED='{{#templateChanged "config/main.conf"}}'
FOLLOWER='{{svc.me.follower}}'
PID='{{pkg.svc_pid_file}}'

if [[ "$NETWORK_CHANGED" == true ]]; then
  echo "Network change requires restart"
  kill "$PID"
  exit 0
fi

if [[ "$MAIN_CHANGED" == "true" ]] && [[ "$FOLLOWER" == true ]]; then
  echo "Restarting because of config change on follower"
  kill "$PID"
  exit 0
fi

echo "Trying soft-reload on config change"
kill -1 "$PID"

My real use-case is building postgresql cluster:

  1. when primary_conninfo changes I must restart database, b/o it cannot be reload
  2. however, if server was follower, but now it is leader, I must not restart, ignore primary_conninfo change and just call pg_ctl reaload.
@jsirex jsirex added the C-bug label Apr 27, 2020
@christophermaier christophermaier added A-supervisor Focus :Templating Improvements or bugs related to templated content in the Supervisor and removed C-bug labels Apr 28, 2020
@christophermaier
Copy link
Contributor

This is a good idea, and a nice way to refine exactly how your reconfigure behavior works. We have this information in the Supervisor already (it's how we figure out whether to trigger a reconfigure in the first place), and could potentially pass it into templates directly as part of the data we provide already. That way, helper functions might not be needed.

👍

@christophermaier christophermaier added Focus:Supervisor Related to the Habitat Supervisor (core/hab-sup) component Type: Feature Issues that describe a new desired feature and removed A-supervisor labels Jul 24, 2020
@stale
Copy link

stale bot commented Jul 25, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We value your input and contribution. Please leave a comment if this issue still affects you.

@stale stale bot added the Stale label Jul 25, 2021
@stale
Copy link

stale bot commented Aug 29, 2021

This issue has been automatically closed after being stale for 400 days. We still value your input and contribution. Please re-open the issue if desired and leave a comment with details.

@stale stale bot closed this as completed Aug 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Focus:Supervisor Related to the Habitat Supervisor (core/hab-sup) component Focus :Templating Improvements or bugs related to templated content in the Supervisor Stale Type: Feature Issues that describe a new desired feature
Projects
None yet
Development

No branches or pull requests

2 participants