soyuka / pidusage

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

ESPIPE: invalid seek, read #126

Closed edi closed 3 years ago

edi commented 3 years ago

Hello. So I'm working on an app on the new DigitalOcean Apps Platform, and I'm using PM2 to monitor and restart my app.

The weird thing was I was unable to get a CPU / RAM usage read within PM2, therefore I started digging around, and I've noticed that it triggers this error every 500ms (which is the interval it is sending data at). Since it wasn't obvious what caused this, I noticed that pidusage is one of PM2's dependencies.

So now, here I am, trying to figure out how could this issue be sorted. I imagine it's not an issue on your end but more likely on DO's docker containers config ... reason for which I'll also open a ticket with them.

But until that happens, could someone try explaining what causes this so I could also forward this explanation to them?

Cheers!

[Error: ESPIPE: invalid seek, read] {
  errno: -29,
  code: 'ESPIPE',
  syscall: 'read'
}
soyuka commented 3 years ago

Interesting, but that's really not enough data. This is a linux machine? I'm guessing it uses procFs to read the data and the file is removed while pidusage tries to read it or something like this (https://github.com/soyuka/pidusage/blob/master/lib/procfile.js#L31). You should try calling pidusage with {usePs: true} to see if it fixes the error.

Anyways, pm2 should handle pidusage without breaking your app. Do you have more informations? Unix system, stack trace, enough disk space ?

edi commented 3 years ago

@soyuka thanks for the fast reply. I think this is a generic issue related to containerized apps

  1. You are correct, it does not break my app, but it does generate 2 logs per second which end up using a lot of space in the end, and it clutters my actual logs.

  2. You are also correct with regards to {usePs: true}, this seems to work just fine. Screenshot here

Meanwhile I have found these: https://github.com/Unitech/pm2/issues/4878, https://github.com/Unitech/pm2/issues/4360 related to the same exact issue within PM2.

The line causing troubles within PM2 is this one https://github.com/Unitech/pm2/blob/master/lib/God/ActionMethods.js#L60

So yeah, as I've initially mentioned, this is not an issue with pidusage but with pm2 not using or allowing us to configure the usage of usePs: true.

Thank you very much for the tip, I'll try figure out how I could implement that {usePs: true} with my app's build steps.

jackHedaya commented 3 years ago

Hi @edi, I'm encountering the same issue on Digital Ocean. How did you manage to enable usePs in pm2?

edi commented 3 years ago

Hi @edi, I'm encountering the same issue on Digital Ocean. How did you manage to enable usePs in pm2?

@jackHedaya Please refer to my issue here, https://github.com/Unitech/pm2/issues/5045 which explains exactly how to sort it .

jackHedaya commented 3 years ago

Got it, thank you @edi

soyuka commented 2 years ago

Use PIDUSAGE_USE_PS to configure this.

eazylaykzy commented 1 year ago

Use PIDUSAGE_USE_PS to configure this.

@soyuka an this env var be used with PM2 without explicitly installing pidusage in my decencies? Or the right way to go about this is editing PM2 ActionMethods.js adding the {usePs: true} flag to it?