habitat
habitat copied to clipboard
`hab unload` followed by `hab start` does not usually result in a service restart
Running hab unload
followed by hab start
does not usually result in a service restart.
This isn't necessarily a bug but a consequence of the current hab-sup implementation that might not be clear to users from the documentation alone.
If the unload
and start
happen inside the file_watcher timeout and if the start
command produces the same spec file content that existed on disk before the unload
, no change to the service will occur. A brief skimming of the code seems to indicate that the file-watcher uses a poll-based approach rather than relying on notifications from the operating system.
For example, the following test script will show that the PID does not change on almost every run (the script obviously needs to be modified to use a service that you can start:
#!/bin/bash
TEST_WAIT=5
for i in {1..100}; do
PID_BEFORE=$(cat /hab/svc/authz-service/PID)
hab sup unload chef/authz-service
hab sup start chef/authz-service --channel dev --bind automate-postgresql:automate-postgresql.default
sleep $TEST_WAIT
PID_AFTER=$(cat /hab/svc/authz-service/PID)
if [[ "$PID_AFTER" = "$PID_BEFORE" ]]; then
echo "PID changed: NO ($PID_AFTER)"
else
echo "PID changed: YES ($PID_BEFORE -> $PID_AFTER)"
fi
done
This might be unexpected for some users who have read the documentation which says:
https://www.habitat.sh/docs/habitat-cli/#hab-svc:
If the Supervisor is running when the service is unloaded the service will be stopped.
Hi @stevendanna, I think what you're running into will be addressed by this: https://github.com/habitat-sh/habitat/pull/4805
Not quite yet, #4805 is a predecessor for the change which will address this
Confirmed this is still an issue in 0.56.0, although in 0.56.0 unload is not the right command, rather you can reproduce this with stop followed by start.
The scoping of #4805 was altered a bit so this will actually be resolved when https://github.com/habitat-sh/habitat/issues/1973 is closed
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.
I haven't tested this again but I'm fairly certain this is still an issue.
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.
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.