2013-11-13



Let’s face it, there will be bugs...in my applications and yours. From println/echo debugging to using full-on debuggers, a developer will no doubt spend a portion of his or her time debugging applications. By now, most developers are familiar with the various debugging tools in their local development environment, but as they step towards cloud deployments, how can they achieve the same? Is remote debugging even possible in the cloud? Well of course it is.

We have seen earlier how to debug Java applications in Stackato using the Harbor service. Recently I asked whether or not we can debug Node.js applications in Stackato, and so I took a look at node-inspector.

Straight from the project's README file, "Node Inspector is a debugger interface for node.js using the Blink Developer Tools (former WebKit Web Inspector)."

Without further ado, here are the steps for setting up node-inspector to debug a Node.js application. We'll use haste-server as an example.

Note: The commands in this article are for Stackato version 2.10.6 (based on Cloud Foundry v1). Some of the commands and app config will be slightly different using Stackato 3.0.

Make sure to include node-inspector in your package.json:

Change the default stackato.yml config file to add a
Harbor
port service and a --debug flag to the command used
to start the server:

Target the client, authenticate, then push the application code and config:

Once the app is running, SSH into the app container and run
node-inspector with the port number returned by $STACKATO_HARBOR:

From the local machine, find out the external Harbor port:

Open browser and navigate to http://<app url>:<ext-harbor-port>/debug?port=5858



With the Harbor port service available in Stackato, you can now easily debug your Node.js application running in the cloud with node-inspector. However, like any other awesome feature, it is not without its caveats. In order to run node-inspector, be prepared to increase the memory limit for the application as overhead for the debugger. Also, this approach is for debugging a single instance Node.js application - when scaled out to multiple instances, things can get a little more complicated.

If you are a developer with a Node.js application that you want to move to the cloud, download the Stackato microcloud and give it a try.

-->

Trackback URL for this post:

http://www.activestate.com/trackback/3819

Show more