Home

Awesome

cp-remote   Build Status Coverage Status NPM version

Node.js child_process done remotely, IPC channel intact!

Example:

var cp_remote = require('cp-remote');
var assert = require('assert');
var remote = cp_remote.run('host', '/path/on/host/to/sub.js', 'foo', { answer: 42 });
remote.on('message', function (msg)
{
    assert.deepEqual(msg, { foo: 'bar' });
});
remote.send({ hello: 'world' });

You might implement the remote script, sub.js, like this:

var assert = require('assert');
assert.equal(process.argv[2], 'foo')
assert.deepEqual(process.argv[3], { answer: 42 });
process.on('message', function (msg)
{
    assert.deepEqual(msg, { hello: 'world' });
    process.disconnect();
});
process.send({ foo: 'bar' });

The API is described here.

Pre-requisites

Client:

Remote host:

Installation

npm install cp-remote

Limitation

You can't pass handles to a remote child process like you can with local child processes.

How it works

How it works

Licence

MIT

Test

To test creating and communicating with remote child processes:

grunt test --remote=<host1> --remote=<host2> ...

You can specify as many remote hosts as you like. The test will try to create a remote child process on each host and then communicate with each one.

It assumes the cp-remote module is installed at the same path on each host.

Lint

grunt lint

Code Coverage

grunt coverage --remote=<host1> --remote=<host2> ...

c8 results are available here.

Coveralls page is here.

API

Source: index.js

<a name="tableofcontents"></a>

run(host, module_path)

Run a Node.js module on a remote host and return a child_process.ChildProcess object for communication with it.

Parameters:

Return:

{child_process.ChildProcess} The ChildProcess object for the remote process. You can do the same things with this object as a local ChildProcess, except send it handles (i.e. the optional sendHandle parameter to child.send isn't supported).

<sub>Go: TOC</sub>

—generated by apidox