-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fork mode does not close stdout/stderr files on reload #747
Comments
This has been fixed prior 0.11.1 and next 0.12 release, thanks for the feedback |
We are using 0.12.1 and still seeing this error occur. Did this resolve the issues for others? If so, I will take a closer look to ensure it's not on our end. |
I just tried 0.12.1 and do not see lingering file handles, but this is with a toy app. How high is your log volume? I'm wondering if writes to your logs fall behind and those need to flush before the file handle is finally closed. Does the pm2 continue to have an open file handle to the rotated file-location for a long time? Is that file still changing? |
I believe the issue we were seeing had to do more with permissions. If you are running PM2 as a privileged user and run Thanks for your response. |
This is with 0.9.6, but is likely still a problem in 0.10.8.
Using lsof, I am able to see the
pm2
application retain file handles long after signaling a log-reload. This is because thestdout
andstderr
streams are not closed prior to re-open inForkMode.js
.We start our application with a pm2 command-line like:
You can see
pm2
hanging on to log files with the following steps:I have this patched locally with the following redefinition of
_reloadLogs
inForkMode.js
but am not certain that this is the correct solution which also avoids losing log messages; it is similar to the code already in place inProcessContainer.js
:I expect that these filehandles will be reclaimed when the garbage collector reaps the objects, but this is not always guaranteed to happen.
This is causing a problem for us because these log files are subsequently removed. The filesystem is not reclaiming the space because
pm2
still has a live filehandle; the file is not truly deleted until the filehandle is closed.The text was updated successfully, but these errors were encountered: