Node Monitor v0.6.5

Show:

ReplProbe Class

Extends Probe
Module: Probes

A probe based Read-Execute-Print-Loop console for node.js processes

Constructor

ReplProbe

(
  • initParams
  • model
)

Parameters:

  • initParams Object

    Probe initialization parameters

    • uniqueInstance
      • Usually specified to obtain a unique REPL probe instance
  • model Object

    Monitor data model elements

    • output String

      Last (current) REPL output line

    • sequence Integer

      Increasing sequence number - to enforce unique line output

Methods

_runShellCmd

(
  • command
)
private

Run a shell command and emit the output to the browser.

Parameters:

  • command String
    • The shell command to invoke

autocomplete

(
  • params
  • callback
)

Process an autocomplete request from the client

Parameters:

  • params Object

    Named parameters

  • callback Function(error, returnParams)

    Callback function

initialize

(
  • attributes
  • options
)

Inherited from Probe:

Initialize the probe

This is called on the probe during construction. It contains the probe initialization attributes and an option to make probe construction asynchronous.

Probe implementations can defer the initial response to the monitor until the initial state is loaded. This allows the callback on Monitor.connect() to have the complete initial state of the probe when called.

If the initial probe state cannot be determined in initialize, it should set the options.asyncInit option to true, and call the options.callback(error) once the initial state is determined.

// Asynchronous initialization
options.asyncInit = true;
var callback = options.callback

If asyncInit is set to true, the callback must be called once the initial state of the probe is known (or in an error condition).

// Set the initial state, and call the callback
this.set(...);
callback(null);

See the initialize method of the FileProbe probe for an example. It defers returning the probe to the monitor until the initial file contents are loaded.

Parameters:

  • attributes Object

    Initial probe attributes sent in from the Monitor

  • options Object

    Initialization options

    • asyncInit Boolean

      Set this to TRUE if the initial probe state can't be known immediately.

    • callback Function(error)

      The callback to call if asyncInit is set to true. If an error is passed, the probe will not be used.

input

(
  • params
  • callback
)

Handle user input from the console line

Parameters:

  • params Object

    Named parameters

  • callback Function(error, returnParams)

    Callback function

onControl

(
  • name
  • [params]
  • [callback]
)

Inherited from Probe:

Dispatch a control message to the appropriate control function.

This is called when the control() method of a monitor is called. The name determines the method name called on the probe.

The probe must implement a method with the name {name}_control(), and that method must accept two parameters - an input params and a callback. The callback must be called, passing an optional error and response object.

For example, if the probe supports a control with the name go, then all it needs to do is implement the go_control() method with the proper signature. See ping_control() for an example.

Parameters:

  • name String

    Name of the control message.

  • [params] Any optional

    Input parameters specific to the control message.

  • [callback] Function(error, response) optional

    Called to send the message (or error) response.

    • error (Any) An object describing an error (null if no errors)
    • response (Any) Response parameters specific to the control message.

output

(
  • str
)
protected

Send output to the terminal

This forces the change event even if the last output is the same as this output.

Parameters:

  • str String

    String to output to the repl console

ping_control

(
  • params
  • callback
)

Inherited from Probe:

Respond to a ping control sent from a monitor

Parameters:

  • params Object

    Input parameters (not used)

  • callback Function(error, response)

    Called to send the message (or error) response.

    • error (Any) An object describing an error
    • response (String) The string 'pong' is returned as the response

release

()

Inherited from Probe but overwritten in

Release any resources consumed by this probe.

Stop the REPL console. Consoles live 1-1 with a UI counterpart, so stop requests exit the underlying repl console. If the probe is re-started it will get a new repl stream and console.

sh

(
  • params
  • callback
)

Execute a shell command

Parameters:

  • params Object

    Named parameters

  • callback Function(error, returnParams)

    Callback function