Home > OS >  how to debug app that runs in gcloud shell
how to debug app that runs in gcloud shell

Time:10-26

I run a nodejs app in Google cloud shell. now I want to debug this app using google devtools by node --inspect flag.

I know how to use this feature with an app that runs locally, but I want to use this feature with an app that runs in gcloud shell as if it runs locally.

CodePudding user response:

Please check official Google documentation about it

Cloud Debugger

CodePudding user response:

I've not tried this!

When you start Cloud Shell using gcloud cloud-shell ssh, you can append --verbosity=debug to determine the instance's IP. When you next restart it, port-forward to 8080 (IIRC Cloud Shell permits traffic on 8080 and maybe other ports.):

gcloud cloud-shell ssh --command="-L 8080:localhost:8080"

NOTE I'm unsure how you can determine the Cloud Shell instance's IP using the browser client.

Then you can probably run node --inspect using --inspect=0.0.0.0:8080

If this works correctly, from your localhost (!) Chrome DevTools you should be able to chrome://inspect and select localhost:8080 (because the Cloud Shell port is being forwarded to your localhost).

Again, I've not tried this but that should work.

  • Related