-
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
Errors when using gracefulReload (or reload) #1101
Comments
Hello, thanks for this feedback. |
please let me know if you need any other information. I'm gonna keep working on it and will update if I find anything. |
I'ved tweaked various aspects of my app, but the error persists. Any suggestions? |
How many instances of the app are launched ? |
|
I'm going to refactor reload/gracefulReload a bit, I'll keep you informed. |
Hey, not to pile on, but I'm seeing something similar when executing
But occasionally on our EC2 Ubuntu 14.04 host, when I execute
I have to manually kill the process then and then I use pm2 to restart. Any idea why this might be happening or how to resolve it? |
@davisford When PM2 kills a process it basically sends a 'SIGTERM' signal and waits 800ms for the process to exit, if after 800ms it still doesn't, then PM2 spawns a new process indeed. |
Do you catch 'SIGTERM' signal on purpose anywhere in your code ? |
If you indeed catch SIGTERM in order to perform a graceFul exit (closing all connections etc) and your app takes more than 800ms to do that. We could make this 800ms timeout configurable via an env variable such as PM2_KILL_TIMEOUT so you can set it to 2seconds or whatever it takes. |
Yep, I do catch SIGTERM, so that must be it. I need to gracefully shutdown a few services, and perhaps it is taking longer than 800ms. If you make this configurable that would be awesome 👍 |
Ah interesting, so should my shutdown code look for a eg, instead of
should be:
|
Nop, 'SIGTERM' concerns only fork_mode. |
@davisford Here we go : 33180a9 You have to set it the first time you launch PM2 daemon like this : Cheers. |
No worries at all, I was just trying to see if I'd missed a change along the way. PM2 has been great for us for over a year now, so I'm trying to see what we might be doing "wrong" from a PM@ point of view. |
@bigethan does this bug happen everytime you Can you |
it seemed to happen every time I did a
Also noticed that it's now starting up 8 instances, when I only have 4 cpus?
as opposed to
|
Thanks @jshkurti ! |
@bigethan What's the result of this on your machine with different Node versions ? require('os').cpus().length It might be a Node.js issue. |
|
with node v0.12.2 and pm2 0.12.12, on a cluster of 2 (and a quadcore), on debian wheezy amd64, I have a similar problem :
In the log I found (comment added for this post)
So the lauch of the app.shutdown() can never be done, it seems the process die before |
It seems that pm2 is closing output of process too early, because my |
I have the same error. |
Hi @XadillaX, give us more details please. Which version of PM2 and Node.js were you using ? Thanks |
They are all HTTP or RPC servers. And this occurred while restarting of max memory.
The PM2 God daemon crashed with no notification. We found the daemon is mission and then we restart the daemon manully. Just as the log said. |
Should fix it. |
@jshkurti Thx, and i will check it later. |
I think I'm facing a similar issue where when pm2 tries to reload based on a watch but I sporadically get several EADDRINUSE errors until the port opens up from the previous PM2 process. Is there a way to gracefully close the server of the original process before restarting? |
Every problem listed on that issue will be fixed by upgrading to the latest pm2 version
|
pm2.gracefulReload() is now pm2.reload() Unitech/pm2#1101
Hello.
I'm upgrading PM2 from 0.9.0 to 0.12.7 and with the
pm2 gracefulReload myApp
I'm gettingEADDRINUSE
andTypeError: Cannot read property 'apply' of undefined
errors:It's also missing the logging that I'm doing within my shutdown function in my
index.js
:my json config is:
Any ideas what I'm doing wrong? Any new buttons to push to get this to work properly?
The text was updated successfully, but these errors were encountered: