soyuka / pidusage

Cross-platform process cpu % and memory usage of a PID
MIT License
512 stars 55 forks source link

Allow PIDUSAGE_USE_PS to have string type of "true" #141

Closed basiam closed 1 year ago

basiam commented 2 years ago
Q A
Branch? main
Bug fix? no
New feature? no (well, maybe - I really small one)
Deprecations? no
Tickets no
License MIT
Doc PR

I have been using pm2 on DigitalOcean and wanted to set process.env.PIDUSAGE_USE_PS as per the discussion here https://github.com/Unitech/pm2/issues/5045. But because we are using Node and in Node environment variables are always strings, this comparison below fails for "true" === true or "1" === true etc. https://github.com/soyuka/pidusage/blob/61f63bd9e8f576c4b7b673171dc7262bd3c26ae8/lib/stats.js#L50

The code below makes it work for "true".

ansonkao commented 2 years ago

Who can we tag for visibility here? A lot of people would benefit from this PR! See https://github.com/Unitech/pm2/issues/4360

Apezdr commented 2 years ago

Any chance this could make it in? using digital ocean "app container" and wasn't able to fix the PM2 error: Error caught while calling pidusage error. had to switch to something else.

leerobert commented 2 years ago

I had to do a patch-package in pm2 via https://github.com/Unitech/pm2/issues/4360#issuecomment-1148869202 in order to make this work in digitalocean apps.

This PR would be massive.

soyuka commented 1 year ago

am so sorry I didn't merge early, will get into the next patch!