Marwan
Marwan

Reputation: 1941

Node single file run with multi child process

I'm using NodeJS to run with socket.io. I run the node files from the command line, and when I monitor Node files process and CPU, Memory usage, I found that every node file run 6 times.

Do you have an explanation to this issue ?

Please check the image below, as it describe the processes for every single node file.

enter image description here

and here is the source code, for a mainNode.js file

var express = require('express'),
    http = require('http');
var fs = require('fs');

fs.readFile('connection.config.json', 'utf8',
    function (err, data) {
        if (err) throw err;
        obj = JSON.parse(data);
        var app = express();
        var server = http.createServer(app).listen(obj.main.nodejs.port, "0.0.0.0");
        require('socket.io').listen(server);  // Your app passed to socket.io
    }
);

Upvotes: 0

Views: 77

Answers (1)

trquoccuong
trquoccuong

Reputation: 2873

By default, htop lists each thread of a process separately, while ps doesn't.

try ps aux |grep node

Upvotes: 2

Related Questions