forked from UmbraEngineering/ps
-
Notifications
You must be signed in to change notification settings - Fork 41
Open
Labels
Description
ps-node version: "0.1.6"
table-parser version: "0.1.3"
I've been running a node process for a while now without problems that uses ps-node every few minutes. But I also run a few other CPU intensive processes on the machine.
One day it stopped working, maybe due to PIDs, used memory, or total CPU time getting too high. I didn't step through TableParser to find where it goes wrong. I've supplied some code here with my output (with some process names and arguments redacted) that will recreate the problem.
Maybe it's time to switch from Unix ps to using something like:
https://www.npmjs.com/package/procps
// Output copied from calling console.log() within ps-node/index.js's parseGrid function
var psoutput = `F UID PID PPID PRI NI VSZ RSS WCHAN STAT TTY TIME COMMAND
4 1000 3002 1 20 0 45248 0 ep_pol Ss ? 0:00 /lib/systemd/systemd --user
5 1000 3006 3002 20 0 163688 4 - S ? 0:00 (sd-pam)
0 1000 3101 1 20 0 9657524 6355656 poll_s Sl ? 1440:57 mysqld --datadir /aa/aa/aa
0 1000 3178 1 20 0 808752 247892 hrtime Sl ? 11234:03 ./aa -aa /aa/aa/aa/aa.aa -aa /aa/aa/aa/aa/aa/aa/aa -aa /aa/aa/aa/aa/aa/bb/bb.bb.bb.bb -t 4 -bb /cc/cc/cc/cc/cc/cc/cc.cc -cc /a/a/a/a/a/a/a.a
0 1000 3198 1 20 0 639312 0 hrtime Sl ? 3:54 ./h -d /a/a/a -p 3
0 1000 9215 1 20 0 1879292 95352 ep_pol Sl ? 47:06 node ./d/d
0 1000 12547 1 20 0 1931424 21016 ep_pol Sl ? 0:14 node app.js --prod
0 1000 17244 1 20 0 1450676 190724 ep_pol Sl ? 226:10 node app.js --prod
1 1000 17789 1 20 0 79940 44376 - S ? 17:43 tor --runasdaemon 1
5 1000 21352 21325 20 0 113860 1236 - S ? 0:01 sshd: user@pts/8
0 1000 21353 21352 20 0 22676 3804 wait_w Ss+ pts/8 0:00 -bash
5 1000 21675 21647 20 0 113868 1232 - S ? 0:00 sshd: user@pts/9
0 1000 21676 21675 20 0 22788 4748 wait Ss pts/9 0:00 -bash
0 1000 21973 21676 20 0 920496 28816 ep_pol Sl+ pts/9 0:00 node
0 1000 21987 21973 20 0 28916 1500 - R+ pts/9 0:00 ps lx`;
// Try parsing and view the output
var TableParser = require('table-parser');
var garbledTable = TableParser.parse(psoutput);
console.log(garbledTable);