lib/worker/Worker.js
function jobDone(err, data) {
        // TODO: check if function was already called before

        // check if we close the connection after this (to prevent memory leaks)
        var closing = totalRequests > REQUESTS_BEFORE_WORKER_RESTART ? true : false;

        var msg = {};

        if (err) {
            msg.errMessage = err.message;
            msg.status = 'fail';
            closing = true; // always close the worker if any error happens
        } else {
            msg.status = 'success';
        }
        msg.data = data;
        msg.closing = closing;

        // send our data back to the master
        res.statusCode = 200;
        res.write(JSON.stringify(msg));
        res.close();

        // close this worker if necessary
        if (closing) {
            phantom.exit();
        }
    }
function jobDone(err, data) {
        // TODO: check if function was already called before

        // check if we close the connection after this (to prevent memory leaks)
        var closing = totalRequests > REQUESTS_BEFORE_WORKER_RESTART ? true : false;

        var msg = {};

        if (err) {
            msg.errMessage = err.message;
            msg.status = 'fail';
            closing = true; // always close the worker if any error happens
        } else {
            msg.status = 'success';
        }
        msg.data = data;
        msg.closing = closing;

        // send our data back to the master
        res.statusCode = 200;
        res.write(JSON.stringify(msg));
        res.close();

        // close this worker if necessary
        if (closing) {
            phantom.exit();
        }
    }
function jobDone ( err , data ) { // TODO: check if function was already called before // check if we close the connection after this (to prevent memory leaks) var closing = totalRequests > REQUESTS_BEFORE_WORKER_RESTART ? true : false ; var msg = { } ; if ( err ) { msg . errMessage = err . message ; msg . status = 'fail' ; closing = true ; // always close the worker if any error happens } else { msg . status = 'success' ; } msg . data = data ; msg . closing = closing ; // send our data back to the master res . statusCode = 200 ; res . write ( JSON . stringify ( msg ) ) ; res . close ( ) ; // close this worker if necessary if ( closing ) { phantom . exit ( ) ; } }
job was executed, lets inform the master
job was executed lets inform the master