Adding check for existing ssh tunnel

This commit is contained in:
Finley Ghosh 2025-12-07 16:15:36 +11:00
parent 942522458f
commit 6668e1af4f

View file

@ -29,10 +29,14 @@ else
SSH_PORT=13308
fi
# Create SSH tunnel
echo "Creating SSH tunnel to $TARGET database on localhost:$SSH_PORT..."
ssh -f -N -L $SSH_PORT:localhost:$DB_PORT cmc
sleep 2
# Create SSH tunnel if not already running
if ! lsof -ti:$SSH_PORT > /dev/null 2>&1; then
echo "Creating SSH tunnel to $TARGET database on localhost:$SSH_PORT..."
ssh -f -N -L $SSH_PORT:localhost:$DB_PORT cmc
sleep 2
else
echo "SSH tunnel already exists on localhost:$SSH_PORT, reusing it..."
fi
# Load goose.env and override the port
GOOSE_ENV_FILE="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../go" && pwd)/goose.env"