-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathssh-api.sh
More file actions
executable file
·47 lines (37 loc) · 1.1 KB
/
Copy pathssh-api.sh
File metadata and controls
executable file
·47 lines (37 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
# Script to make it easy to tunnel into the currently running API instance on GCP
# so that you can debug the Node process, e.g. to set breakpoints (in dev!!), use the REPL,
# or do performance or memory profiling.
set -e
SERVICE_NAME="api"
SERVICE_GROUP="${SERVICE_NAME}-group"
ZONE="us-west1-c"
#ENV=${1:-dev}
ENV=prod
case $ENV in
dev)
GCLOUD_PROJECT=compass-130ba ;;
prod)
GCLOUD_PROJECT=compass-130ba ;;
*)
echo "Invalid environment; must be dev or prod."
exit 1
esac
echo "Looking for API instance on ${GCLOUD_PROJECT} to talk to..."
INSTANCE_ID=$(gcloud compute instances list \
--filter="zone:(us-west1-c)" \
--sort-by="~creationTimestamp" \
--format="value(name)" \
--limit=1)
#echo "Forwarding debugging port 9229 to ${INSTANCE_ID}. Open chrome://inspect in Chrome to connect."
if [ "$1" = "logs" ]; then
CMD=(--command="sudo docker logs -f \$(sudo docker ps -alq)")
else
CMD=()
fi
gcloud compute ssh "${INSTANCE_ID}" \
--project="${GCLOUD_PROJECT}" \
--zone="${ZONE}" \
"${CMD[@]}"
# -- \
# -NL 9229:localhost:9229