Code Monkey home page Code Monkey logo

Comments (3)

lorenwest avatar lorenwest commented on July 2, 2024

They're handled quite nicely. What specifically do you want to know about them? Node-monitor connects many processes together.

from node-monitor.

noam-arad avatar noam-arad commented on July 2, 2024

Excellent to hear.
I am developing an app using "cluster" and wanted to monitor the app as a whole but wasn't sure this module has the capability. I'll give it a test. Thanks

from node-monitor.

jijordre avatar jijordre commented on July 2, 2024

Hi Loren
Would you be able to elaborate a bit on this connection of processes done by node-monitor?

In my case I have an app using cluster that goes something like this:

// index.js

var restify = require('restify');
var os = require('os');
var cluster = require('cluster');
var config = require('config');
var Monitor = require('monitor');

var monitorServer = new Monitor.Server();
monitorServer.on('start', function () {
    console.log('Monitor server listening at port %d', monitorServer.get('port'));
});
monitorServer.start();

var nodes = Math.min(process.env.NODES || 1, os.cpus().length - 1);
if (cluster.isMaster) {
    console.log('Master %d creating %d forks', process.pid, nodes);
    for (var i = 0; i < nodes; i++) {
        cluster.fork();
    }

    cluster.on('online', function (worker) {
        console.log('Worker %d is online', worker.process.pid);
    });

    cluster.on('exit', function (worker, code, signal) {
        cluster.fork();
    });

} else {
    var server = restify.createServer({
        name: 'Monitored RESTified API'
    });

    server.listen(8080, function () {
        console.log('%s server listening at %s', server.name, server.url);
    });
}

Now, if e.g. I run this app with 5 forks, it logs as follows:

$ NODES=5 node index.js
Master 4945 creating 5 forks
Monitor server listening at port 42000
Worker 4946 is online
Worker 4949 is online
Worker 4948 is online
Worker 4950 is online
Worker 4947 is online
Monitored RESTified API server listening at http://0.0.0.0:8080
Monitor server listening at port 42001
Monitored RESTified API server listening at http://0.0.0.0:8080
Monitor server listening at port 42001
Monitored RESTified API server listening at http://0.0.0.0:8080
Monitor server listening at port 42001
Monitored RESTified API server listening at http://0.0.0.0:8080
Monitor server listening at port 42001
Monitored RESTified API server listening at http://0.0.0.0:8080
Monitor server listening at port 42001

Then starting up monitor-dashboard I find two monitor server app instances, whose PIDs are the ones of the master and the last fork.

By connection do you mean that these two monitor server app instances include values from all of my 6 running processes? Alternatively, is there a way to assure the creation of one monitor server app instance per node process, 6 in total in my case?

from node-monitor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.