#!/usr/bin/env node
var log = require('./src/log.js'),
    Parent = require('./src/parent.js'),
    ctrl = require('daemonctrl'),
    currentParent = new Parent(),
    config, sender;

function onExit(error) {
    currentParent.stop();
    ctrl.end();
    if (error) {
        throw e;
    }
    process.exit();
}
process.on('exit', onExit);
process.on('SIGTERM', onExit);
process.on('SIGINT', onExit);

//we gotta first strip the command otherwise flags will complain
ctrl.strip();
currentParent.loadConfig();
ctrl.socketOptions({path: currentParent.config.controlsock});
if (!currentParent.config.controlsock) {
    currentParent.start();
    return;
}
sender = ctrl.send();
if (!sender) {
    log('Starting parent');
    currentParent.start();
    return;
}
sender.pipe(process.stdout);

#!/usr/bin/env node
var log = require('./src/log.js'),
    Parent = require('./src/parent.js'),
    ctrl = require('daemonctrl'),
    currentParent = new Parent(),
    config, sender;

function onExit(error) {
    currentParent.stop();
    ctrl.end();
    if (error) {
        throw e;
    }
    process.exit();
}
//since each of our children are going to be listening on all 3 of these raise the max listeners limit
process.setMaxListeners(32);
process.on('exit', onExit);
process.on('SIGTERM', onExit);
process.on('SIGINT', onExit);

//we gotta first strip the command otherwise flags will complain
ctrl.strip();
currentParent.loadConfig();
ctrl.socketOptions({path: currentParent.config.controlsock});
if (!currentParent.config.controlsock) {
    currentParent.start();
    return;
}
sender = ctrl.send();
if (!sender) {
    log('Starting parent');
    currentParent.start();
    return;
}
sender.pipe(process.stdout);

Raise maxListeners so if you have 16 cores it doesn't complain
Raise maxListeners so if you have 16 cores it doesn't complain
