tunnel, keep the loop in the foreground so that the output makes it to the log.

This commit is contained in:
me committed 2026-11-06 14:53:16 -07:00
1 parent bbffe8c69a
commit f587ca1e5e
1 file changed
+12 -14
+12 -14
View File
@@ -60,20 +60,18 @@
exec 2>&1 exec 2>&1
# Health check to ensure connection does not go stale. # Health check to ensure connection does not go stale.
( while true; do
while true; do sleep 300
sleep 300 echo -n "RUN-LOOP: "
echo -n "RUN-LOOP: " nc -zv {{ tunnel_remote_host }} {{ tunnel_remote_port }}
nc -zv {{ tunnel_remote_host }} {{ tunnel_remote_port }} status="$?"
status="$?" echo "RUN-LOOP: Port check returned ${status}."
echo "RUN-LOOP: Port check returned ${status}." if [[ "$status" != 0 ]]; then
if [[ "$status" != 0 ]]; then echo "RUN-LOOP: Restarting service."
echo "RUN-LOOP: Restarting service." sv restart {{ tunnel_service_name }}
sv restart {{ tunnel_service_name }} fi
fi echo "RUN-LOOP: Going back to sleep."
echo "RUN-LOOP: Going back to sleep." done &
done
) &
# Do not use `exec` here otherwise the loop may get killed. # Do not use `exec` here otherwise the loop may get killed.
chpst -u {{ user }} ssh -v -N \ chpst -u {{ user }} ssh -v -N \