Virtual size in docker is always increasing with puppeteer - node.js

I am developing a little program with nodejs and Puppeteer which goal is to generate a certain amount of PDF files. The program is working with the bluebird module in order to achieve concurrency. The problem is that the use of Physical and virtual memory does not stop to increase. The size of all the generated documents is approximately 25GB, but the used memory in the docker container is much bigger:
pdf-generator 64.2GB (virtual 68.4GB)
We generate the PDF with Puppeteer in this way:
async function generatePDF(browser, num) {
const page = await browser.newPage();
try {
const pdfUrl = pdfPathURL(num);
await page.goto(pdfUrl, {
waitUntil: ["domcontentloaded", "networkidle0", "load"],
timeout: 300000,
});
// await page.waitForLoadState({ waitUntil: "domcontentloaded" });
const buffer = await page.pdf({
format: "A4",
printBackground: true,
landscape: true,
preferCSSPageSize: true,
});
await page.close()
return buffer.toString("base64");
} catch (error) {
let messageError = error;
console.log(messageError);
return "";
}
} finally {
await page.close();
}
}
[EDIT]
This is the code that opens the Chromium instance. One per request:
async function generatePDFFile(id) {
let pdfFile;
let errorGeneration = "";
const browser = await launchPuppeteer();
try {
if (!browser) {
errorGeneration = `Error getting Chromium instance`;
}
if (!browser.isConnected()) {
errorGeneration = `Error connecting to Chromium`;
}
pdfFile = await generatePDFPage(browser, id);
console.log(`PDF file generated of id:`, id);
} catch (error) {
errorGeneration = error;
console.log("errorGeneration: ", error);
}
finally {
await browser.close();
}
return { id, pdf: pdfFile, error: errorGeneration };
}
const puppeteerParams = {
headless: true,
args: [
"--disable-gpu",
"--disable-dev-shm-usage",
"--disable-setuid-sandbox",
"--no-sandbox",
"--font-render-hinting=none",
'--single-process',
'--no-zygote'
],
};
The top command in the container
Tasks: 19 total, 1 running, 18 sleeping, 0 stopped, 0 zombie
%Cpu(s): 45.4 us, 11.0 sy, 0.0 ni, 42.5 id, 0.3 wa, 0.0 hi, 0.9 si, 0.0 st
MiB Mem : 15862.5 total, 1418.4 free, 9686.2 used, 4757.9 buff/cache
MiB Swap: 2048.0 total, 1291.0 free, 757.0 used. 4953.4 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
34855 myuser 20 0 1124.8g 222708 149664 S 81.0 1.4 0:02.74 chrome
34810 myuser 20 0 1124.8g 212544 146712 S 77.3 1.3 0:02.61 chrome
34918 myuser 20 0 1124.8g 184764 141052 S 36.7 1.1 0:01.10 chrome
31 myuser 20 0 706628 142100 33080 S 35.7 0.9 2:19.22 node
34968 myuser 20 0 1124.7g 136748 112832 S 9.3 0.8 0:00.28 chrome
35062 myuser 20 0 1124.7g 138452 114036 S 9.0 0.9 0:00.27 chrome
35013 myuser 20 0 1124.8g 137448 113456 S 8.3 0.8 0:00.25 chrome
60 myuser 20 0 965160 103512 33040 S 7.7 0.6 0:22.25 node
35106 myuser 20 0 1124.6g 105352 89208 S 5.0 0.6 0:00.15 chrome
8 myuser 20 0 630596 51892 32908 S 0.7 0.3 0:04.14 node
1 myuser 20 0 2420 524 452 S 0.0 0.0 0:00.05 sh
19 myuser 20 0 707412 57724 35064 S 0.0 0.4 0:02.26 npm start
30 myuser 20 0 2420 580 512 S 0.0 0.0 0:00.00 sh
48 myuser 20 0 705296 53336 34512 S 0.0 0.3 0:01.71 npm run example
59 myuser 20 0 2420 524 456 S 0.0 0.0 0:00.00 sh
24495 myuser 20 0 1124.7g 140500 116068 S 0.0 0.9 0:00.31 chrome
31812 myuser 20 0 4100 3376 2948 S 0.0 0.0 0:00.05 bash
31920 myuser 20 0 7012 3420 2848 R 0.0 0.0 0:00.03 top
34415 myuser 20 0 1124.8g 138368 114276 S 0.0 0.9 0:00.28 chrome
There are 8 chrome processes because I am concurrently doing 8 requests. The memory continues increasing

Related

Sharp fails on resize with zsh: killed

I have a small node script to resize images for a website:
const sharp = require('sharp')
const fsp = require('fs/promises')
const path = require('path')
const FILES = [
'/home/xx/68/ea/68ea8c14c2b655c50cbc560b9f3a5af620882670.jpeg',
'/home/xx/4e/7f/4e7f94103480d8ff231b17310c598470dc10489c.jpeg',
]
const SIZES = [ 300, 500, 800, 1024, 2048 ]
const FORMATS = [ 'jpeg' ]
const dir = '/home/xx/media/temp/'
async function generatePreviews(pathName, name) {
const image = sharp(pathName)
const metadatas = await image.metadata()
console.log('format:', metadatas.format)
console.log('width:', metadatas.width)
console.log('height:', metadatas.height)
console.log('weight:', await fsp.stat(pathName))
for (const size of SIZES) {
for (const format of FORMATS) {
console.log('start create preview', name, format, size)
try {
await image.clone()
.resize(size, size, {fit: 'inside'})
.toFile(path.join(dir, `preview_${name}_${size}.${format}`))
console.log('Preview created', name, format, size)
} catch (e) {
console.log('An error occured')
console.log(e)
}
}
}
}
async function testPreviews() {
console.log('start generating previews')
for (let i = 0; i < FILES.length; i++) {
await generatePreviews(FILES[i], i)
}
console.log('All previews generated')
}
testPreviews()
It works perfectly on my desktop computer (old i5 760 from 2010), but on my server, it fails almost silently when generating the largest previews for the largest file…
Here is the output on the server:
% node ./src/scripts/test_sharp.js
start generating previews
format: jpeg
width: 683
height: 1024
weight: Stats {
dev: 51713,
mode: 33188,
nlink: 1,
uid: 1001,
gid: 1001,
rdev: 0,
blksize: 4096,
ino: 658937,
size: 473209,
blocks: 928,
atimeMs: 1654021875500.3074,
mtimeMs: 1467568028343.9807,
ctimeMs: 1645954831869.6965,
birthtimeMs: 1645954825541.6052,
atime: 2022-05-31T18:31:15.500Z,
mtime: 2016-07-03T17:47:08.344Z,
ctime: 2022-02-27T09:40:31.870Z,
birthtime: 2022-02-27T09:40:25.542Z
}
start create preview 0 jpeg 300
Preview created 0 jpeg 300
start create preview 0 jpeg 500
Preview created 0 jpeg 500
start create preview 0 jpeg 800
Preview created 0 jpeg 800
start create preview 0 jpeg 1024
Preview created 0 jpeg 1024
start create preview 0 jpeg 2048
Preview created 0 jpeg 2048
format: jpeg
width: 3840
height: 5760
weight: Stats {
dev: 51713,
mode: 33188,
nlink: 1,
uid: 1001,
gid: 1001,
rdev: 0,
blksize: 4096,
ino: 658752,
size: 2272667,
blocks: 4440,
atimeMs: 1654021876468.3223,
mtimeMs: 1468007124640.3523,
ctimeMs: 1645954169924.1448,
birthtimeMs: 1645954151475.8787,
atime: 2022-05-31T18:31:16.468Z,
mtime: 2016-07-08T19:45:24.640Z,
ctime: 2022-02-27T09:29:29.924Z,
birthtime: 2022-02-27T09:29:11.476Z
}
start create preview 1 jpeg 300
Preview created 1 jpeg 300
start create preview 1 jpeg 500
Preview created 1 jpeg 500
start create preview 1 jpeg 800
zsh: killed node ./src/scripts/test_sharp.js
It fails at 800px side preview generation for the largest file (5760 x 3840px).
The catch block doesn't trigger…
Server is a 1 CPU VPS with 1GB of RAM (hosted at gandi.net).
% node --version
v16.15.0
% yarn list --pattern sharp 1 Jun 04:06:40
yarn list v1.22.18
└─ sharp#0.30.6
Done in 1.49s.
Any help would be appreciated :)

Write to a sysfs node, causing the system always write to the node

I locally wirte a module to test function/feature, And I create follow node info:
/sys/class/dbc/dbc # ls -l
total 0
-rw------- 1 root root 4096 2021-10-08 21:52 dbc_backlight
-rw------- 1 root root 4096 2021-10-08 22:30 dbc_pwm_max
-rw------- 1 root root 4096 2021-10-08 22:30 dbc_pwm_min
-rw------- 1 root root 4096 2021-10-08 21:52 dbc_setting
-rw------- 1 root root 4096 2021-10-08 21:52 dbc_thread_enable
-r--r--r-- 1 root root 4096 2021-10-08 22:30 dev
drwxr-xr-x 2 root root 0 2021-10-08 22:30 power
lrwxrwxrwx 1 root root 0 2021-10-08 22:30 subsystem -> ../../../../class/dbc
-rw-r--r-- 1 root root 4096 2021-10-08 22:30 uevent
when I echo right value to dbc_backlight node, can normally work, but when I write error value to dbc_backlight node, will result always write, info is follow:
node source code is follow:
static ssize_t dbc_backlight_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
unsigned int DBC_BACKLIGHT = 0;
int readCount = 0;
printk("===========Set DBC Backlight========\n");
readCount = sscanf(buf, "%d", &DBC_BACKLIGHT);
if (readCount != 1)
{
printk("[ERROR] cannot read DBC_BACKLIGHT from [%s] \n", buf);
return 0;
}
if (DBC_BACKLIGHT > 100)
{
printk("Invalid Parameter DBC_BACKLIGHT=%d \n", DBC_BACKLIGHT);
return 0;
}
printk("Set Parameter DBC_BACKLIGHT=%d success\n", DBC_BACKLIGHT);
m_u8BacklightSetting = DBC_BACKLIGHT;
SetActiveBacklightSwitch(m_eActiveBackLight, m_u8BacklightSetting);
return count;
}
abnormal status dmesg log info is:
[ 2562.416693] ===========Set DBC Backlight========
[ 2562.416739] Invalid Parameter DBC_BACKLIGHT=101
[ 2562.416786] ===========Set DBC Backlight========
[ 2562.416832] Invalid Parameter DBC_BACKLIGHT=101
[ 2562.416878] ===========Set DBC Backlight========
[ 2562.416960] Invalid Parameter DBC_BACKLIGHT=101
[ 2562.417006] ===========Set DBC Backlight========
[ 2562.417089] Invalid Parameter DBC_BACKLIGHT=101
[ 2562.417135] ===========Set DBC Backlight========
[ 2562.417181] Invalid Parameter DBC_BACKLIGHT=101
[ 2562.417265] ===========Set DBC Backlight========
[ 2562.417309] Invalid Parameter DBC_BACKLIGHT=101
[ 2562.417391] ===========Set DBC Backlight========
[ 2562.417436] Invalid Parameter DBC_BACKLIGHT=101
[ 2562.417481] ===========Set DBC Backlight========
[ 2562.417564] Invalid Parameter DBC_BACKLIGHT=101
the log will always running and can't stop, otherwise, kill -9 pid can kill(kill pid can't kill it), top info is follow:
Tasks: 410 total, 2 running, 349 sleeping, 0 stopped, 0 zombie
Mem: 1694992k total, 1583088k used, 111904k free, 12844k buffers
Swap: 409596k total, 13056k used, 396540k free, 732388k cached
400%cpu 6%user 102%nice 135%sys 157%idle 0%iow 0%irq 0%sirq 0%host
PID USER PR NI VIRT RES SHR S[%CPU] %MEM TIME+ ARGS
2272 logd 30 10 34M 9.4M 4.1M S 152 0.5 2:29.57 logd
10181 root 20 0 4.4M 2.3M 1.9M R 98.6 0.1 1:33.14 sh -
kill -9 10181 can stop thread running.
I don't know why always write the node(dbc_backlight), please help me.
And locally, I do follow modify, the problem will not reproduce:
printk("===========Set DBC Backlight========\n");
readCount = sscanf(buf, "%d", &DBC_BACKLIGHT);
if (readCount != 1)
{
printk("[ERROR] cannot read DBC_BACKLIGHT from [%s] \n", buf);
return 0;
}
if (DBC_BACKLIGHT > 100)
{
printk("Invalid Parameter DBC_BACKLIGHT=%d \n", DBC_BACKLIGHT);
return 0;
}
//modify follow will fix it the problem
printk("===========Set DBC Backlight========\n");
readCount = sscanf(buf, "%d", &DBC_BACKLIGHT);
if (readCount != 1)
{
printk("[ERROR] cannot read DBC_BACKLIGHT from [%s] \n", buf);
return -EINVAL; //........
}
if (DBC_BACKLIGHT > 100)
{
printk("Invalid Parameter DBC_BACKLIGHT=%d \n", DBC_BACKLIGHT);
return -EINVAL;........
}
Do you know why? thanks for your help.
On success, .store function should return number of characters written.
In fail, it should return negative error code.
Returning 0 (return 0;) from that function is incorrect.
As you correctly noted, you can use return -EINVAL; for indicate that input is invalid.

NodeJs runs again to reach Number of Processes limit in cPanel

I'm using shared hosting cPanel service.
I have ran a NodeJs application on server and everything is ok.
but after server backup runs in every day one NodeJs process add to the running processes and I can see these processes on terminal.
I have killed the processes but they came back after server backup!!!
I have write a code to exit from processes that run when port is busy:
tcpPortUsed.check(port, '127.0.0.1')
.then(function(inUse) {
console.log(`Port ${port} usage: `+inUse);
if (inUse) {
process.exit();
} else {
app.listen(port, () =>
console.log(`server is running on port: ${port}`)
);
}
}, function(err) {
console.error('Error on check:', err.message);
});
but the problem has remained...
this is the terminal after I run ps aux:
user 5435 1.0 0.0 9916 1820 pts/0 S 16:50 0:00 /bin/bash -l
user 5752 0.0 0.0 49844 1684 pts/0 R+ 16:50 0:00 ps aux
user 13658 0.0 0.1 1155556 36060 ? Sl 05:15 0:06 lsnode:/home1/user/node-server/
user 32346 0.0 0.1 1091012 37944 ? Sl Jul04 0:05 lsnode:/home1/user/node-server/

Beginning and pausing SVG animations on hover

I would like to animate the gears on the following SVG when the user hovers over it. That is, when the mouse enters, both gears begin rotating where they left off. When the mouse leaves, the gears stop in whatever position they're in. If possible I would like the animation to begin and end using an ease-in/out function. How can this be done using SVG animations?
Codepen
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="256" height="256" viewBox="0 0 256 256">
<path d="M249.363 80.921l-6.402-15.451c-1.769-4.267-6.659-6.292-10.927-4.528l-9.032 3.7 c-8.043-12.801-18.893-23.646-31.692-31.689l3.744-9.032c1.768-4.266-0.258-9.162-4.528-10.926l-15.45-6.402 c-4.264-1.764-9.16 0.261-10.923 4.523l-3.744 9.032c-14.458-3.293-29.542-3.478-44.817 0l-3.74-9.028 c-1.768-4.267-6.659-6.292-10.926-4.528l-15.451 6.402c-4.267 1.768-6.296 6.656-4.528 10.926l3.744 9 C71.893 41 61 51.9 53 64.687l-9.032-3.744c-4.263-1.764-9.158 0.261-10.927 4.528l-6.398 15.5 c-1.768 4.3 0.3 9.2 4.5 10.926l9.028 3.74c-3.349 14.666-3.435 29.8 0 44.816l-9.028 3.7 c-4.271 1.768-6.296 6.664-4.528 10.926l6.398 15.451c1.772 4.3 6.7 6.3 10.9 4.524l9.032-3.741 c8.044 12.8 18.9 23.6 31.7 31.693l-3.74 9.032c-1.768 4.3 0.3 9.2 4.5 10.927l15.451 6.4 c4.267 1.8 9.158-0.257 10.926-4.528l3.74-9.028c14.613 3.3 29.7 3.4 44.8 0l3.739 9 c1.768 4.3 6.7 6.3 10.9 4.528l15.45-6.402c4.267-1.768 6.292-6.663 4.524-10.927l-3.744-9.032 c12.8-8.048 23.649-18.896 31.692-31.693l9.032 3.741c4.268 1.8 9.158-0.254 10.927-4.524l6.398-15.451 c1.768-4.262-0.257-9.162-4.524-10.922l-9.032-3.739c3.328-14.583 3.458-29.682 0-44.825l9.032-3.74 C249.103 90.1 251.1 85.2 249.4 80.921z M138 176.536c-32.278 0-58.537-26.259-58.537-58.536 c0-32.281 26.259-58.536 58.537-58.536c32.276 0 58.5 26.3 58.5 58.536C196.535 150.3 170.3 176.5 138 176.536z">
<animateTransform
attributeName="transform"
repeatCount="indefinite"
type="rotate"
from="00 138 118"
to="+360 138 118"
begin="0s" dur="30s"/>
</path>
<path d="M57.552 217.745l-2.16 0.895c0.811 3.6 0.8 7.2 0 10.721l2.16 0.895c1.021 0.4 1.5 1.6 1.1 2.612l-1.53 3.7 c-0.423 1.021-1.593 1.506-2.613 1.082l-2.16-0.895c-1.924 3.061-4.519 5.655-7.58 7.58l0.895 2.2 c0.423 1.02-0.062 2.19-1.082 2.613l-3.695 1.531c-1.021 0.422-2.191-0.063-2.614-1.083l-0.895-2.16 c-3.508 0.801-7.12 0.821-10.719 0l-0.895 2.159c-0.423 1.021-1.593 1.506-2.613 1.083l-3.695-1.53 c-1.021-0.423-1.505-1.594-1.082-2.613l0.895-2.16c-3.062-1.924-5.656-4.519-7.581-7.58l-2.16 0.9 c-1.021 0.424-2.189-0.061-2.613-1.082l-1.53-3.695c-0.423-1.02 0.062-2.19 1.083-2.613l2.159-0.895 c-0.801-3.507-0.821-7.121 0-10.719l-2.159-0.895c-1.021-0.424-1.506-1.594-1.083-2.613l1.53-3.696 c0.423-1.021 1.594-1.505 2.613-1.083l2.161 0.896c1.924-3.062 4.519-5.655 7.58-7.579l-0.896-2.16 c-0.423-1.021 0.063-2.19 1.083-2.613l3.695-1.531c1.021-0.422 2.2 0.1 2.6 1.083l0.895 2.159c3.427-0.78 7.035-0.839 10.7 0 l0.895-2.16c0.422-1.02 1.593-1.504 2.612-1.082l3.695 1.531c1.021 0.4 1.5 1.6 1.1 2.613l-0.895 2.2 c3.061 1.9 5.7 4.5 7.6 7.579l2.161-0.896c1.021-0.422 2.2 0.1 2.6 1.083l1.531 3.7 C59.057 216.2 58.6 217.3 57.6 217.745z M46 224c0-7.721-6.28-14-14-14s-14 6.279-14 14c0 7.7 6.3 14 14 14 S46 231.7 46 224z">
<animateTransform
attributeName="transform"
repeatCount="indefinite"
type="rotate"
from="00 32 224"
to="-360 32 224"
begin="0s" dur="20s"/>
</path>
</svg>
Assuming the cogs have id big and little, here's a way to do this using css animations:
#big {
transform-origin: 138px 118px;
animation-duration: 30s;
animation-name: rotateBig;
animation-fill-mode: forwards;
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-play-state: paused;
}
#little {
transform-origin: 32px 224px;
animation-duration: 20s;
animation-name: rotateLittle;
animation-fill-mode: forwards;
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-play-state: paused;
}
#big:hover, #little:hover {
animation-play-state: running;
}
#keyframes rotateBig {
to {
transform: rotate(360deg);
}
}
#keyframes rotateLittle {
to {
transform: rotate(-360deg);
}
}
See live example. This animates each of the gears individually when hovered.
For something that animates both gears when the whole svg is hovered:
#big {
transform-origin: 138px 118px;
animation-duration: 30s;
animation-name: rotateBig;
animation-fill-mode: forwards;
animation-timing-function: linear;
animation-iteration-count: infinite;
}
#little {
transform-origin: 32px 224px;
animation-duration: 20s;
animation-name: rotateLittle;
animation-fill-mode: forwards;
animation-timing-function: linear;
animation-iteration-count: infinite;
}
svg > * {
animation-play-state: paused;
}
svg:hover > * {
animation-play-state: running;
}
#keyframes rotateBig {
to {
transform: rotate(360deg);
}
}
#keyframes rotateLittle {
to {
transform: rotate(-360deg);
}
}
See live example. The only difference is what selectors set animation-play-state.
You may have to resort to using css vendor prefixes to get this to be more compatible, but I've provided it in the cleanest form I could. The fiddle works fine in Opera 25, Chrome 38 and Firefox Nightly 34 at least.
A slight downside with the solution here is that the begin and end isn't using ease-in-out, this is because that makes the repetitions visible. If anyone has a clever idea for how to fix that without using script I'm all ears.
You are almost there. Add this tweaks:
Add id="gear1" to first <path...>
Add id="gear2" to second <path...>
End both <path... with this onmouseover=runGears(); onmouseout=stopGears(); >
remove <animate .....> from both <path....>
On the JS magic to rotate the gears, use this code:
var animateGears ; // event handler
var angle = 0; // rotation of angle
var gear1 = document.getElementById("gear1");
var gear2 = document.getElementById("gear2");
function runGears() {
animateGears = setInterval( function () {
angle += 5;
if (angle == 360 ) { angle = 0 } ; // 360 == 0 degrees
gear1.setAttribute("transform", "rotate(" + angle + " 138 118)");
gear2.setAttribute("transform", "rotate(" + angle + " 32 224)");
}, 100);
}
function stopGears() {
clearInterval(animateGears);
}
Note: play around with the Timeout of 100ms and Angle of +5 to make it look smoother.
Update: The other JS coding that may work for you (without removing the <animate....):-
var svgDoc = document.getElementsByTagName('svg');
svgdoc[0].pauseAnimations(); // pause animation at load time
function runGears() {
svgDoc[0].unpauseAnimations(); // resumes ALL animations
}
function stopGears() {
svgDoc[0].pauseAnimations(); // pause ALL animations
}

how to get the list of process

I am playing around with node and just installed it on my machine. Now I want to get a list of processes running on my machine so I can see whether Apache is running, MySQL is started, etc? How can I do that? I just have very basic code in my js file. I don't even know where to begin on this.
Here is my code:
var http = require('http');
http.createServer(function(request, response){
response.writeHead(200);
response.write("Hello world");
console.log('Listenning on port 1339');
response.end();
}).listen(8080);
As far as I know there isn't a module (yet) to do this cross-platform. You can use the child process API to launch tools that will give the data you want. For Windows, just launch the built-in tasklist process.
var exec = require('child_process').exec;
exec('tasklist', function(err, stdout, stderr) {
// stdout is a string containing the output of the command.
// parse it and look for the apache and mysql processes.
});
See ps-node
To get a list of processes in node:
var ps = require('ps-node');
ps.lookup({
command: 'node',
arguments: '--debug',
}, function(err, resultList ) {
if (err) {
throw new Error( err );
}
resultList.forEach(function( process ){
if( process ){
console.log( 'PID: %s, COMMAND: %s, ARGUMENTS: %s', process.pid, process.command, process.arguments );
}
});
});
ps-list is a better node package for the job, it is working on Linux, BSD, and Windows platforms too.
const psList = require('ps-list');
psList().then(data => {
console.log(data);
//=> [{pid: 3213, name: 'node', cmd: 'node test.js', cpu: '0.1'}, ...]
});
You can also use current-processes which lists all the processes.
https://www.npmjs.com/package/current-processes
The result includes name,pid,cpu and memory used by process.
You can also sort the result and limit the number of processes.
The result looks like this:
[ Process {
pid: 31834,
name: 'atom',
cpu: 84,
mem: { private: 19942400, virtual: 2048, usage: 0.4810941724241514 } }]
Solution for unix-like systems:
const child_process = require('child_process');
const displayProcessBy = (pattern) => {
let command = `ps -aux | grep ${pattern}`;
child_process.exec(command, (err, stdout, stdin) => {
if (err) throw err;
console.log(stdout);
});
}
Examples usage and results
displayProcessBy("nodejs");
setivol+ 7912 0.0 0.0 12732 2108 ? S 10:56 0:00 grep nodejs
setivol+ 12427 0.0 0.0 669552 712 pts/3 Tl Dec16 0:00 nodejs
setivol+ 14400 0.0 0.0 669552 644 pts/2 Tl Dec15 0:00 nodejs
setivol+ 14412 0.0 0.0 670576 224 pts/3 Tl Dec16 0:00 nodejs
setivol+ 14567 0.0 0.0 669552 436 pts/3 Tl Dec15 0:00 nodejs
setivol+ 14911 0.0 0.0 669552 0 pts/3 Tl Dec15 0:00 nodejs
setivol+ 15489 0.0 0.0 669552 712 pts/3 Tl Dec16 0:00 nodejs
setivol+ 15659 0.0 0.0 669520 0 pts/3 Tl Dec16 0:00 nodejs --harmony
setivol+ 16469 0.0 0.0 669520 704 pts/3 Tl Dec16 0:00 nodejs --harmony
setivol+ 20514 0.0 0.0 669552 664 pts/2 Tl Dec15 0:00 nodejs
displayProcessBy("python2")
setivol+ 8012 0.0 0.0 4336 712 ? S 10:58 0:00 /bin/sh -c ps -aux | grep python2
setivol+ 8014 0.0 0.0 12728 2240 ? S 10:58 0:00 grep python2
Testing environment
$ uname -a
Linux localhost 3.16.0-4-amd64 #1 SMP Debian 3.16.36-1+deb8u2 (2016-10-19) x86_64 GNU/Linux
$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 8.6 (jessie)
Release: 8.6
Codename: jessie
Seems there isn't any direct methods
but below videos might help.
Monitoring Long Running Processes with Node. (http://www.youtube.com/watch?v=zamGXhjim00)
CPU usage in real time with node.js & socket.io (http://www.youtube.com/watch?v=bPYgx9V6qAk)
Use the command line tools rather than node scripts.
ps -aef | grep node
This would list the visual studio code helpers and .nvm env processes. We can exclude them using
ps -aef | grep node | grep -v "Visual Studio" | grep -v ".nvm"
Additional tip to kill all the listed processes:
killall node

Resources