Skip to content

katonahmike/trans-parent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

trans-parent

Easily expose stats from long-running node processes via websockets.

Installation

npm install --save @katonahmike/trans-parent

Usage

const trans = require('@katonahmike/trans-parent');

trans.create({
  port : 8888, // Pick a port number and listen for connections
  procName : 'Test', // Name the process that's exposing its stats
  autoUpdateCpuStats : true, // Do you want automatic cpu stat updates?
  cpuUpdateInterval : 3000 // How frequently? Default is 10s (10000)
});

trans.broadcast('SOME_MESSAGE',{ some : 'data' });

trans.destroy() // When you're finished pushing stats

Useful for long-running processes like web crawlers. Simply creating an instance with autoUpdateCpuStats : true and you get periodic cpu info broadcast to all listeners with a message type of 'CPU_UPDATE'. Initial connections receive a message type of 'CONNECTION_ACCEPTED' and the process name you specified on creation.

Any time during the life of your process, update stats with your own message type and value. Values can be any type, including strings, numbers, arrays and objects:

trans.broadcast('RECORDS_PROCESSED',{
    numRecordsProcessed : 3097,
    numRecordsRemaining : 28752
})

Create your own web or mobile dashboard and connect to the process using a library like socket.io-client

About

Easily expose information about long-running node processes via websockets

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published