-
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 reload doesn't send SIGINT signal on cluster mode #2333
Comments
Just tried here, looks like the SIGINT is catched by the application in cluster mode, but the log message does not show via pm2 logs. Tests have been added to verify this behavior, now inspecting pm2 logs |
The way the Reload feature is implemented today does not permit to output log on exit (when inside the SIGINT callback). |
I think this is an important issue because when you use the reload feature, with a SIGINT callback, it is because you want to do some gracefull shutdown ,allowing the application to finish any work was initiated by requests that came into the application just before the graceful shutdown. So usually we put a timer (for example 30 seconds), so that the application can finish calling whatever callback is still in the event queue. During that time we have all logs that we putted everywhere in application code. This means that when we reload with pm2 we lost all logs for all application code that is executed during the 30 seconds jobs. And this means also that in production we will lose a lot of logs |
Nope, all your logs are still stored in the files. This is a minor bug, it's only about the PM2 log command that does not display the log output. These logs are stored anyway in the log files and the SIGINT callback is called for gracefull shutdown. |
Ah ok if it is like you say it is perfect, i will check this behaviour my side |
Sorry my explanation was not so crystal clear :) Anyway, we plan to create a new TCP LB in the following months |
But how can Pm2 continue to write logs (to files) when we disconnect the worker from the cluster master process? |
@markmenox Actually the problem come from a weird behavior on cluster mode, we added a documentation here to describe the problem. We can't really make deeper inspection so feel free to try find an explanation. |
Regarding cluster mode and Each worker in the cluster would receive a Short of getting a |
@Lalem001 Worker can receive |
SIGINT handle now works as expected (it will be called every time the process get exited). To try it:
|
Patch available on pm2@2.1.4 (main): $ npm install pm2 -g
$ pm2 update |
If reporting a bug, please use the following template.
Expected behaviour
When using the command:
pm2 reload idOfPm2Process
on a cluster of pm2 processes, pm2 should send a SIGINT signal to the process that we can catch in a listener as:
process.on('SIGINT', function() {
console.log('SIGINT signal catched')
});
...
Actual behaviour
It seems no signal is sent to the process because no log message is sent to the output/console.
If i do the same thing on a process in fork mode it works perfecrly
...
Steps to reproduce
...
Software versions used
PM2 Log output
Use the command:
tail --lines 50 ~/.pm2/pm2.log
cf CONTRIBUTING.md for more informations
The text was updated successfully, but these errors were encountered: