
╰─$ cf -vcf version 7.2.0+be4a5ce2b.2020-12-10cf login command is used.cf login [-a API_URL] [-o ORG] [-s SPACE] [--sso]API-URL is your API endpoint (for example, https://api.cf.eu20.hana.ondemand.com).ORG is the org name where your application is deployed. Orgs map to business units have quota plans and unique roles.SPACE is the space in the organization where your application is deployed. Spaces map to teams or products, hold applications, and have unique roles.--sso Prompt for a one-time passcode to log in. SAP Single Sign-On is the safest and most recommended way to log in.The org name, API endpoint, and space information can be found in the SAP BTP Cockpit under Home → Regions → Global Accounts → Subaccounts.

SAP BTP Cockpit Overview
cf login command:╰─$ cf login -a https://api.cf.eu20.hana.ondemand.com -o myorg -s myspace --sso
API endpoint: https://api.cf.eu20.hana.ondemand.com
Temporary Authentication Code ( Get one at https://login.cf.eu20.hana.ondemand.com/passcode 
--sso option, the Cloud Foundry CLI will display the API endpoint and prompt you for one-time passcode to log in.
SAP BTP SAP Single Sign-On

SAP BTP Temporary Authentication Code
Temporary Authentication Code ( Get one at https://login.cf.eu20.hana.ondemand.com/passcode 
Authenticating...
OK
Targeted org myorg.
Targeted space myspace.
API endpoint: https://api.cf.eu20.hana.ondemand.com
API version: 3.99.0
user: myemail@sap.com
org: myorg
space: myspace
╰─$ cf ssh-enabled myapp
ssh support is enabled for app 'myapp'.cf enable-ssh.╰─$ cf enable-ssh myapp
Enabling ssh support for app myapp as youremail@sap.com...
...
OK╰─$ cf restart myappAssuming SSH access is allowed at the deployment, space, and application level, you can initiate an interactive SSH session with the VM hosting the application by running the following command:
╰─$ cf ssh myappvcap@afa9bea3-b619-6476-5e97-1328:~$ps command to obtain this information. Here's an example:vcap@afa9bea3-b619-6476-5e97-1328:~$ ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
vcap 151 0.0 0.1 687580 118376 ? Sl May28 0:05 node /home/vcap/deps/0/bin/npx cds run
...Once the PID of the Node.js process running the application is known, you can use the kill command to send a debugging signal to it. The Node.js runtime activates the inspector protocol when it receives a usr1 signal. The inspector protocol is more or less a debugging protocol that allows tools to instrument, inspect, debug, and profile.
vcap@afa9bea3-b619-6476-5e97-1328:~$ kill -usr1 151After sending this signal to the Node.js process, inspect the application logs. You should see that a debugger is now listening on ws://127.0.0.1:9229/48d7a94b-acb8-4d43-9932-95b781ee932d, this indicates that the Node.js process has switched to debug mode and is actively listening for debugging request on a WebSocket server located at host and port 127.0.0.1:9229.
SAP BTP Cockpit Application Logs
cf ssh command,the-Lflag enables local port forwarding, binding an output port on your machine to an input port on the application VM. Pass in a local port and your application VM port and port number, all colon-delimited. You can prepend your local network interface or use the defaultlocalhost.
Enables local port forwarding
$ cf ssh MY-APP -L [LOCAL-NETWORK-INTERFACE:]LOCAL-PORT:REMOTE-HOST-NAME:REMOTE-HOST-PORTcf ssh command:cf ssh -N -L 9229:127.0.0.1:9229 myappThis command initiates an SSH tunnel session where a connection to port 9229 on your development environment is forwarded to the myapp instance on port 9229.
Now, you can attach a debugger such as Visual Studio Code, SAP Business Application Studio (BAS) or Chrome DevTools to localhost:9229. With this setup, you'll be able to debug your application instance running on SAP BTP, Cloud Foundry environment as if the Node.js application were running locally.
launch.json file:{
"name": "Attach to a Cloud Foundry Instance on Port 9229",
"port": 9229,
"request": "attach",
"type": "node",
"localRoot": "${workspaceFolder}",
"remoteRoot": "/home/vcap/app"
}
VS Code Debug Configuration



VS Code Debugger Console, Loaded Scripts ...
Open the Chrome browser (or any Chromium-based browser) and enter chrome://inspect in the address bar. If you're using Microsoft Edge, it also supports the V8 JavaScript engine and can be used for debugging.

Chrome Browser Window

Chrome Browser Window (Inspect Devices)

Chrome DevTools Node.js Debugger

Chrome Debugger Console Panel

Chrome Debugger Sources Panel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 4246 | |
| 3357 | |
| 2603 | |
| 2153 | |
| 1983 | |
| 1255 | |
| 1164 | |
| 1122 | |
| 1100 |