tunnel, keep the loop in the foreground so that the output makes it to the log.
This commit is contained in:
1 parent
bbffe8c69a
commit
f587ca1e5e
1 file changed
+12
-14
@@ -60,20 +60,18 @@
|
||||
exec 2>&1
|
||||
|
||||
# Health check to ensure connection does not go stale.
|
||||
(
|
||||
while true; do
|
||||
sleep 300
|
||||
echo -n "RUN-LOOP: "
|
||||
nc -zv {{ tunnel_remote_host }} {{ tunnel_remote_port }}
|
||||
status="$?"
|
||||
echo "RUN-LOOP: Port check returned ${status}."
|
||||
if [[ "$status" != 0 ]]; then
|
||||
echo "RUN-LOOP: Restarting service."
|
||||
sv restart {{ tunnel_service_name }}
|
||||
fi
|
||||
echo "RUN-LOOP: Going back to sleep."
|
||||
done
|
||||
) &
|
||||
while true; do
|
||||
sleep 300
|
||||
echo -n "RUN-LOOP: "
|
||||
nc -zv {{ tunnel_remote_host }} {{ tunnel_remote_port }}
|
||||
status="$?"
|
||||
echo "RUN-LOOP: Port check returned ${status}."
|
||||
if [[ "$status" != 0 ]]; then
|
||||
echo "RUN-LOOP: Restarting service."
|
||||
sv restart {{ tunnel_service_name }}
|
||||
fi
|
||||
echo "RUN-LOOP: Going back to sleep."
|
||||
done &
|
||||
|
||||
# Do not use `exec` here otherwise the loop may get killed.
|
||||
chpst -u {{ user }} ssh -v -N \
|
||||
|
||||
Reference in new issue
Block a user