|
| 1 | +--- |
| 2 | +title: Running an Application with OpenShift Toolkit |
| 3 | +sidebar_position: 1 |
| 4 | +--- |
| 5 | + |
| 6 | +Debugging is an unavoidable part of development, and it can prove even more difficult when developing an application that runs remotely. |
| 7 | + |
| 8 | +However, this task is made absurdly simple with the help of OpenShift Toolkit. |
| 9 | + |
| 10 | +## OpenShift Toolkit |
| 11 | +[OpenShift Toolkit](https://github.com/redhat-developer/intellij-openshift-connector) is an IDE plugin that allows you to do all things that `odo` does, i.e. create, test, debug and deploy cloud-native applications on a cloud-native environment in simple steps. |
| 12 | +`odo` enables this plugin to do what it does. |
| 13 | + |
| 14 | +## Prerequisites |
| 15 | +1. [You have logged in to your cluster](../../quickstart/nodejs.md#step-1-connect-to-your-cluster-and-create-a-new-namespace-or-project). |
| 16 | +2. [You have initialized a Node.js application with odo](../../quickstart/nodejs.md#step-2-initializing-your-application--odo-init-). |
| 17 | +3. Open the application in the IDE. |
| 18 | +4. Install OpenShift Toolkit Plugin in your preferred VS Code or a Jet Brains IDE. |
| 19 | + |
| 20 | +In the plugin window, you should be able to see the cluster you are logged into in "APPLICATION EXPLORER" section, and your component "my-nodejs-app" in "COMPONENTS" section. |
| 21 | + |
| 22 | + |
| 23 | +## Step 1. Start the Dev session to run the application on cluster |
| 24 | + |
| 25 | +Right click on "my-nodejs-app" and select "Start on Dev". |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | +Wait until the application is running on the cluster. |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | +Our application is now available at 127.0.0.1:20001. The debug server is running at 127.0.0.1:20002. |
| 34 | + |
| 35 | +## Step 2. Start the Debugging session |
| 36 | + |
| 37 | +Right click on "my-nodejs-app" and select "Debug". |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | +Debug session should have started successfully at the debug port, in this case, 3000. And you must be looking at the "DEBUG CONSOLE". |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | +## Step 3. Set Breakpoints in the application |
| 46 | + |
| 47 | +Now that the debug session is running, we can set breakpoints in the code. |
| 48 | + |
| 49 | +Open 'server.js' file if you haven't opened it already. We will set a breakpoint on Line 55 by clicking the red dot that appears right next to line numbers. |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | +From a new terminal, or a browser window, ping the url at which the application is available, in this case, it is 127.0.0.1:20001. |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | +The debug session should halt execution at the breakpoint, at which point you can start debugging the application. |
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | +To learn more about running and debugging an application on cluster with OpenShift Toolkit, see the links below. |
| 63 | +1. [Using OpenShift Toolkit - project with existing devfile](https://www.youtube.com/watch?v=2jfV0QqG8Sg) |
| 64 | +2. [Using OpenShift Toolkit with two microservices](https://www.youtube.com/watch?v=8SpV6UZ23_c) |
| 65 | +3. [Using OpenShift Toolkit - project without devfile](https://www.youtube.com/watch?v=sqqznqoWNSg) |
0 commit comments