-
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
pm2-docker in watch and restart mode causes pm2 to exit sometimes #3206
Comments
I am seeing the exact same behavior. Race condition; PM2 randomly exits with code 0 when the app being watched is being restarted (perhaps a check happens, seeing there's nothing running [in the middle of a restart] and PM2 exits). Naturally happens when using --auto-exit Edit: pm2/lib/binaries/Runtime4Docker.js Lines 122 to 161 in 43b6000
|
Is anyone willing to do a small PR to fix this issue? That would be very appreciated https://github.com/Unitech/pm2/blob/master/lib/binaries/Runtime4Docker.js |
I can probably find some time to do it, but how would you like to fix it? Should we add a |
Since the flag is already here, you can just do something like this :
|
I am seeing this race condition as well. Very interested in seeing this fixed. |
Seems to hang even without a watch... We currently use pm2-docker on an aws instance. |
Fixed. Changelog: 2.9.0 CHANGELOG Update procedure: npm install pm2 -g
pm2 update |
I don't think it's safe to consider this resolved with the addition of the flag to disable auto exit - the intended functionality of auto-exit (which is useful for docker) still suffers from a race condition. Remember that this new flag is simply a workaround for the underlying issue. Unless you mean the race condition is actually fixed in 2.9.0... I have not tested it |
Although the workaround works, I can confirm the root of the issue has not been resolved as of 2.10.1. I ran into the problem when I started using How to reproduce?
|
I'm having the same issue. |
This is definitely happening |
@Unitech Please reopen until issue is resolved |
@Unitech to further clarify this is happening on a fresh build from |
We need to be less aggressive on the shutdown: https://github.com/Unitech/pm2/blob/master/lib/binaries/Runtime4Docker.js#L173 @quinn if you have suggestions on patching this let me know please I think we will do 2 to 3 checks before exiting the pm2-docker. |
@quinn it should be good now, just update to the latest pm2:
Closing, if you have any issue re-open it thanks |
Thanks for the update. I don't think the fix is really solving the underlying problem. It now waits a bit longer, but whenever you've configured Steps to reproduce;
Would it be an idea to to add |
fix: reinforce pm2-runtime auto exit strategy Unitech#3567 Unitech#3206
What's going wrong?
For local development, I work inside a Docker container. When I use pm2-docker with watch mode on, pm2 frequently quits after I change a file. I get the following trace:
I did some debugging and found this commit. My guess is that there is a race condition between the setInterval in the autoExit function and the application restarting. If it doesn't restart fast enough, autoExit is triggered.
How could we reproduce this issue?
Try pm2-docker with watch mode on, and change a file repeatedly.
Supporting information
I saw the rationale for making autoExit the default for pm2-docker, but the option is still in the CLI, even though the code doesn't seem to check for it. I think either the flag should be used to turn off autoExit, or it should be removed from the CLI if it doesn't actually do anything.
In the meantime, I switched to using pm2-dev, which is working so far.
The text was updated successfully, but these errors were encountered: