Skip to content

Instantly share code, notes, and snippets.

@msukmanowsky
Last active August 29, 2015 14:19
Show Gist options
  • Save msukmanowsky/ba9d09fcee74de96bc24 to your computer and use it in GitHub Desktop.
Save msukmanowsky/ba9d09fcee74de96bc24 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Hitting CTRL-C kills the Django server as well as all tunnels that were created
TUNNEL_PIDS=()
function kill_tunnels() {
for tunnel_pid in "${TUNNEL_PIDS[@]}"
do
kill $tunnel_pid
done
}
trap kill_tunnels EXIT
ssh -nNL 27017:localhost:27017 [email protected] &
TUNNEL_PIDS+=($!)
echo "MongoDB tunnel started."
ssh -nNL 5432:localhost:5432 [email protected] &
TUNNEL_PIDS+=($!)
echo "PostgreSQL tunnel started."
# Start Django server
python manage.py runserver 0.0.0.0:5000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment