Skip to content
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

Graceful Exit #1732

Closed
benjsicam opened this issue Oct 31, 2015 · 7 comments
Closed

Graceful Exit #1732

benjsicam opened this issue Oct 31, 2015 · 7 comments

Comments

@benjsicam
Copy link

Might be related to #729 and fe92e71

We are a pm2 and keymetrics user.

We handle graceful exit of child processes on SIGINT. However, the process is killed even before the graceful exit function is called. This is because after you issue a process.kill(pid, 'SIGINT') call, you immediately kill the process tree.

@soyuka
Copy link
Collaborator

soyuka commented Nov 3, 2015

Cluster or fork?

@benjsicam
Copy link
Author

Cluster.

@benjsicam
Copy link
Author

Ok, the graceful exit handler on our SIGINT and SIGTERM had to be synchronous functions. We used node fibers in order to execute all our cleanup functions before PM2 kills the process.

@lklepner
Copy link

Can you provide a code sample?

@benjsicam
Copy link
Author

I think this is now handled by the kill_timeout option.

@Unitech
Copy link
Owner

Unitech commented Oct 31, 2016

The issue was that we called disconnect() on processes in cluster, throwing all the exit logic. Now it has been fixed:

$ npm install pm2@next -g
$ pm2 update

@Unitech
Copy link
Owner

Unitech commented Nov 7, 2016

Patch available on pm2@2.1.4 (main):

$ npm install pm2 -g
$ pm2 update

@Unitech Unitech closed this as completed Nov 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants