src/dashboard/index.js
function bindIndicators(indicator) {
    // Parent process will send three type of data
    const collectorHandler = {
        'process': function (value) {
            indicator.rss = value.rss;
            indicator.heapTotal = value.heapTotal;
            indicator.heapUsed = value.heapUsed;
        },
        'os': function (value) {
            indicator.totalMem = value.totalMem;
            indicator.freeMem = value.freeMem;
            indicator.cpus = value.cpus;
        },
        'v8': function (value) {
            indicator.newSpace = value.heapSpace[0];
            indicator.oldSpace = value.heapSpace[1];
            indicator.codeSpace = value.heapSpace[2];
            indicator.mapSpace = value.heapSpace[3];
            indicator.largeObjectSpace = value.heapSpace[4];
        }
    }

    process.on('message', (msg) => {
        if (Array.isArray(msg)) {
            msg.forEach((data) => {
                let handler = collectorHandler[data.type];
                if (typeof handler === 'function') collectorHandler[data.type](data.value);
            });
        }
    });
}
function bindIndicators(indicator) {
    // Parent process will send three type of data
    const collectorHandler = {
        'process': function (value) {
            indicator.rss = value.rss;
            indicator.heapTotal = value.heapTotal;
            indicator.heapUsed = value.heapUsed;
        },
        'os': function (value) {
            indicator.totalMem = value.totalMem;
            indicator.freeMem = value.freeMem;
            indicator.cpus = value.cpus;
        },
        'v8': function (value) {
            indicator.newSpace = value.heapSpace[0];
            indicator.oldSpace = value.heapSpace[1];
            indicator.codeSpace = value.heapSpace[2];
            indicator.mapSpace = value.heapSpace[3];
            indicator.largeObjectSpace = value.heapSpace[4];
        }
    }

    process.on('message', (msg) => {
        if (Array.isArray(msg)) {
            msg.forEach((data) => {
                let handler = collectorHandler[data.type];
                if (typeof handler === 'function') collectorHandler[data.type](data.value);
            });
        }
    });
}
function bindIndicators ( indicator ) { // Parent process will send three type of data const collectorHandler = { 'process' : function ( value ) { indicator . rss = value . rss ; indicator . heapTotal = value . heapTotal ; indicator . heapUsed = value . heapUsed ; } , 'os' : function ( value ) { indicator . totalMem = value . totalMem ; indicator . freeMem = value . freeMem ; indicator . cpus = value . cpus ; } , 'v8' : function ( value ) { indicator . newSpace = value . heapSpace [ 0 ] ; indicator . oldSpace = value . heapSpace [ 1 ] ; indicator . codeSpace = value . heapSpace [ 2 ] ; indicator . mapSpace = value . heapSpace [ 3 ] ; indicator . largeObjectSpace = value . heapSpace [ 4 ] ; } } process . on ( 'message' , ( msg ) => { if ( Array . isArray ( msg ) ) { msg . forEach ( ( data ) => { let handler = collectorHandler [ data . type ] ; if ( typeof handler === 'function' ) collectorHandler [ data . type ] ( data . value ) ; } ) ; } } ) ; }
Bind process IPC channel to indicator
Bind process IPC channel to indicator