I have a large node.js project that deals with the linux redhat filesystem quite a bit, and is being managed by PM2. I'm using fs and rimraf for disk cleanup on a redhat AWS ephemeral drive.
When running through all of the disk cleanup operations, the files are deleted, but kept open by node.js until it's restarted. Using df
shows that the disk is full, but du
shows the disk as clean, which would make sense.
It's my understanding that when using fs
, if you use fs.open
you need to call fs.close
, but these functions are never in use. The fs operations I'm using are:
fs.writeFile
fs.readdirSync
fs.lstatSync
fs.existsSync
fs.mkdirSync
fs.chownSync
fs.unlink
fs.rmdirSync
fs.writeFile
fs.createReadStream
fs.createWriteStream
Rimraf is also being used, but looking through their code, I don't think that's the problem.
I believe all of these functions manage closing themselves, according to the documentation, but if somebody knows something I didn't see that help would be appreciated.
My other fear is that pm2
is somehow keeping files open, is that possible?