1.0.2 • Published 9 years ago

respawner v1.0.2

Weekly downloads
3
License
ISC
Repository
github
Last release
9 years ago

respawner

Description

respawner is a simple module that spawns a specified child process on a set interval.

Installation

npm install respawner

Example

var Respawner = require('respawner');

var respawner = new Respawner('/path/to/process', '-arg1 -arg2');

respawner.on('exit', function (data) {
    console.log('Process exited. Data returned: ' + data);
});

respawner.start(10000); // Spawns a new process every 10 seconds.

API

Respawner

Spawns a child process at a set interval.

Kind: global class

new Respawner(path, args)

Initializes a new instance of respawner.

ParamTypeDescription
pathStringThe child process command.
argsStringThe arguments to the spawned process.

respawner.start(interval)

Starts spawning the child process.

Kind: instance method of Respawner

ParamTypeDefaultDescription
intervalNumber60000The spawn interval in milliseconds.

respawner.stop(stopNow)

Stops spawning the child process.

Kind: instance method of Respawner

ParamTypeDefaultDescription
stopNowBooleantrueTrue to stop spawning immediately, false to stop after the next spawn.

"error"

'error' event. Is emitted if the child process cannot be spawned.

Kind: event emitted by Respawner

"exit"

'exit' event. Is emitted when the child process exits. All concatenated data from the child process's stdout is returned.

Kind: event emitted by Respawner

"data"

'data' event. Is emitted when data is received from the child process's stdout.

Kind: event emitted by Respawner