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

No "shutdown" message is sent when the service is stopped #95

Open
gissahh opened this issue Dec 11, 2023 · 0 comments
Open

No "shutdown" message is sent when the service is stopped #95

gissahh opened this issue Dec 11, 2023 · 0 comments

Comments

@gissahh
Copy link

gissahh commented Dec 11, 2023

Description

I have a service that should do some cleanup before stopping.

This way runs successful:

  1. pm2 is running as service
  2. in an admin console I start the service with pm2 start service.js --kill-timeout 10000 --shutdown-with-message
  3. in the admin console I enter manually pm2 stop all
  4. the service received successfully the shutdown message

But if instead of point 4 I stop the service with net stop pm2.exe, no message is sent to my service.

In the service I use this to catch the message:

process.on('message', msg => {
    if (msg === 'shutdown') {
        console.log('shutdown');
    }
});

Is there another way to do this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant