Node Inspector provides two ways of embedding in third-party applications.
Add message
handler to get notified about Node Inspector events, use
msg.event
to check which event was emitted.
var fork = require('child_process').fork;
var inspectorArgs = [];
var forkOptions = { silent: true };
var inspector = fork(
require.resolve('node-inspector/bin/inspector'),
inspectorArgs,
forkOptions
);
inspector.on('message', handleInspectorMessage);
function handleInspectorMessage(msg) {
switch(msg.event) {
case 'SERVER.LISTENING':
console.log('Visit %s to start debugging.', msg.address.url);
break;
case 'SERVER.ERROR':
console.log('Cannot start the server: %s.', msg.error.code);
break;
}
}
Emitted when the HTTP server was bound and is ready to accept connections.
Properties:
address
- Server address as returned by DebugServer.address()
(see
below).Emitted when there was an error while setting up the HTTP server.
Properties:
error
- The error.To be done. index.js should expose method for creating and starting a DebugServer instance with a given config.
DebugServer is already exposing the following API:
Returns the result of server.address()
plus the URL of the Node Inspector
page to open in browser.
Example:
{
port: 8080,
address: '0.0.0.0',
url: 'http://localhost:8080/debug?port=5858'
}
Emitted when the HTTP server was bound and is ready to accept connections.
Emitted when there is an error in setting up the HTTP server.