node package manager
Easy sharing. Manage teams and permissions with one click. Create a free org »

carcass-monitor

Carcass Monitor

A simple wrap of forever-monitor, in Carcass style.

This is only meant to be used in tests where you need to start and stop some scripts easily. For production, use forever or equivalent.

Quick Example

In a Mocha test:

var Monitor = require('carcass-monitor');
 
describe('Something:', function() {
    var monitor = new Monitor();
 
    before(function(done) {
        /**
         * Each stack will be started with an instance of forever Monitor, in
         *   the syntax of:
         *
         * `new forever.Monitor('something', {...other_options...});`
         */
        monitor.stack({
            script: 'something',
            sourceDir: 'somewhere',
            options: ['some', 'options']
        }).stack(...).start(done);
    });
 
    after(function(done) {
        monitor.close(done);
    });
 
    ...
});

APIs

Instantiate

var monitor = new Monitor([id])

ID is optional; defaults to a random string.

Add an item

monitor.stack(options)

Returns the monitor itself so it's chain-able. options is an object and will be used to instantiate a forever.Monitor, with options.script as the first argument, and the others as the second. See forever-monitor's document for details.

Can be used multiple times to add multiple items.

Start

monitor.start(done)

Starts all the items; returns the monitor itself.

Close

monitor.close(done)

Closes (stops) all the items; returns the monitor itself.