Skip to content

Ready signal not respected anymore #2996

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

Closed
jiripospisil opened this issue Jul 3, 2017 · 6 comments
Closed

Ready signal not respected anymore #2996

jiripospisil opened this issue Jul 3, 2017 · 6 comments

Comments

@jiripospisil
Copy link

What's going wrong?
There seems to be a regression causing the ready signal to be ignored by PM2.

How could we reproduce this issue?

{
    "apps": [
        {
            "exec_mode": "cluster_mode",
            "instances": 1,
            "wait_ready": true,
            "listen_timeout": 10000,
            "kill_timeout": 10000,
            "name": "test",
            "script": "test.js",
            "log_date_format": "YYYY-MM-DD HH:mm:ss Z",
        }
    ]
}
'use strict';

let workInterval = null;

console.log('Started');

setTimeout(() => {
    console.log('Ready');
    process.send('ready');
    workInterval = setInterval(() => console.log('Working'), 1000);
}, 5000);

process.once('SIGINT', () => {
    clearInterval(workInterval)
    console.log('Received SIGINT, exiting in 5 seconds');
    setTimeout(() => {
        console.log('Exiting...'); // This might not display because of EL delay, that's fine
        process.exit(0);
    }, 5000);
});
  1. Run the app using 2.4.6 and then do pm2 reload test:
0|test     | 2017-07-03 13:35:43 +02:00: Working
0|test     | 2017-07-03 13:35:44 +02:00: Working
0|test     | 2017-07-03 13:35:45 +02:00: Working
0|test     | 2017-07-03 13:35:45 +02:00: Started
_old_0|tes | 2017-07-03 13:35:46 +02:00: Working
_old_0|tes | 2017-07-03 13:35:47 +02:00: Working
_old_0|tes | 2017-07-03 13:35:48 +02:00: Working
_old_0|tes | 2017-07-03 13:35:49 +02:00: Working
_old_0|tes | 2017-07-03 13:35:50 +02:00: Working
0|test     | 2017-07-03 13:35:50 +02:00: Ready                    #1
_old_0|tes | 2017-07-03 13:35:50 +02:00: Received SIGINT, exiting in 5 seconds        #2
0|test     | 2017-07-03 13:35:51 +02:00: Working
0|test     | 2017-07-03 13:35:52 +02:00: Working
0|test     | 2017-07-03 13:35:53 +02:00: Working
0|test     | 2017-07-03 13:35:54 +02:00: Working
0|test     | 2017-07-03 13:35:55 +02:00: Working
_old_0|tes | 2017-07-03 13:35:55 +02:00: Exiting...
0|test     | 2017-07-03 13:35:56 +02:00: Working
0|test     | 2017-07-03 13:35:57 +02:00: Working
0|test     | 2017-07-03 13:35:58 +02:00: Working
0|test     | 2017-07-03 13:35:59 +02:00: Working

At #1 the worker declares itself as ready. Right after the old worker receives SIGINT #2 and starts to exit. All good.

  1. Do the same but with 2.5.0 (I also tested with the development version 2.5.1 with the same result):
0|test     | 2017-07-03 13:31:03 +02:00: Working
0|test     | 2017-07-03 13:31:04 +02:00: Working
0|test     | 2017-07-03 13:31:05 +02:00: Working
0|test     | 2017-07-03 13:31:06 +02:00: Working
0|test     | 2017-07-03 13:31:07 +02:00: Working
0|test     | 2017-07-03 13:31:07 +02:00: Started
_old_0|tes | 2017-07-03 13:31:08 +02:00: Working
_old_0|tes | 2017-07-03 13:31:09 +02:00: Working
_old_0|tes | 2017-07-03 13:31:10 +02:00: Working
_old_0|tes | 2017-07-03 13:31:11 +02:00: Working
_old_0|tes | 2017-07-03 13:31:12 +02:00: Working
0|test     | 2017-07-03 13:31:12 +02:00: Ready                        #1
_old_0|tes | 2017-07-03 13:31:13 +02:00: Working
0|test     | 2017-07-03 13:31:13 +02:00: Working
_old_0|tes | 2017-07-03 13:31:14 +02:00: Working
0|test     | 2017-07-03 13:31:14 +02:00: Working
_old_0|tes | 2017-07-03 13:31:15 +02:00: Working
0|test     | 2017-07-03 13:31:15 +02:00: Working
_old_0|tes | 2017-07-03 13:31:16 +02:00: Working
0|test     | 2017-07-03 13:31:16 +02:00: Working
_old_0|tes | 2017-07-03 13:31:17 +02:00: Working
0|test     | 2017-07-03 13:31:17 +02:00: Working
_old_0|tes | 2017-07-03 13:31:18 +02:00: Working
0|test     | 2017-07-03 13:31:18 +02:00: Working
_old_0|tes | 2017-07-03 13:31:19 +02:00: Working
0|test     | 2017-07-03 13:31:19 +02:00: Working
_old_0|tes | 2017-07-03 13:31:20 +02:00: Working
0|test     | 2017-07-03 13:31:20 +02:00: Working
_old_0|tes | 2017-07-03 13:31:21 +02:00: Working
0|test     | 2017-07-03 13:31:21 +02:00: Working
_old_0|tes | 2017-07-03 13:31:22 +02:00: Working
_old_0|tes | 2017-07-03 13:31:22 +02:00: Received SIGINT, exiting in 5 seconds       #2
0|test     | 2017-07-03 13:31:22 +02:00: Working
0|test     | 2017-07-03 13:31:23 +02:00: Working
0|test     | 2017-07-03 13:31:24 +02:00: Working
0|test     | 2017-07-03 13:31:25 +02:00: Working
0|test     | 2017-07-03 13:31:26 +02:00: Working
_old_0|tes | 2017-07-03 13:31:27 +02:00: Exiting...
0|test     | 2017-07-03 13:31:27 +02:00: Working
0|test     | 2017-07-03 13:31:28 +02:00: Working
0|test     | 2017-07-03 13:31:29 +02:00: Working

At #1 the new worker declares itself ready but the signal is ignored. The old worker receives SIGINT #2 only after the listen_timeout kicks in.

Supporting information

PM2 version: 2.5.0
Node version: v7.9.0
Mac
@Unitech
Copy link
Owner

Unitech commented Jul 4, 2017

Can you try with the development version (probably related to #2956):

$ npm install Unitech/pm2#development -g
$ pm2 update
[...]

@jiripospisil
Copy link
Author

I have already tried that but to make sure I ran it again with the same result:

[email protected]  (git://github.com/unitech/pm2.git#81ed75eed5a79e45c44a8b1840062ee9ab2a35de)
0|test     | 2017-07-04 18:00:50 +02:00: Working
0|test     | 2017-07-04 18:00:51 +02:00: Working
0|test     | 2017-07-04 18:00:51 +02:00: Started
_old_0|tes | 2017-07-04 18:00:52 +02:00: Working
_old_0|tes | 2017-07-04 18:00:53 +02:00: Working
_old_0|tes | 2017-07-04 18:00:54 +02:00: Working
_old_0|tes | 2017-07-04 18:00:55 +02:00: Working
_old_0|tes | 2017-07-04 18:00:56 +02:00: Working
0|test     | 2017-07-04 18:00:56 +02:00: Ready
_old_0|tes | 2017-07-04 18:00:57 +02:00: Working
0|test     | 2017-07-04 18:00:57 +02:00: Working
_old_0|tes | 2017-07-04 18:00:58 +02:00: Working
0|test     | 2017-07-04 18:00:58 +02:00: Working
_old_0|tes | 2017-07-04 18:00:59 +02:00: Working
0|test     | 2017-07-04 18:00:59 +02:00: Working
_old_0|tes | 2017-07-04 18:01:00 +02:00: Working
0|test     | 2017-07-04 18:01:00 +02:00: Working
_old_0|tes | 2017-07-04 18:01:01 +02:00: Working
0|test     | 2017-07-04 18:01:01 +02:00: Working
_old_0|tes | 2017-07-04 18:01:02 +02:00: Working
0|test     | 2017-07-04 18:01:02 +02:00: Working
_old_0|tes | 2017-07-04 18:01:03 +02:00: Working
0|test     | 2017-07-04 18:01:03 +02:00: Working
_old_0|tes | 2017-07-04 18:01:04 +02:00: Working
0|test     | 2017-07-04 18:01:04 +02:00: Working
_old_0|tes | 2017-07-04 18:01:05 +02:00: Working
0|test     | 2017-07-04 18:01:05 +02:00: Working
_old_0|tes | 2017-07-04 18:01:06 +02:00: Working
0|test     | 2017-07-04 18:01:06 +02:00: Working
_old_0|tes | 2017-07-04 18:01:06 +02:00: Received SIGINT, exiting in 5 seconds
0|test     | 2017-07-04 18:01:07 +02:00: Working
0|test     | 2017-07-04 18:01:08 +02:00: Working
0|test     | 2017-07-04 18:01:09 +02:00: Working
0|test     | 2017-07-04 18:01:10 +02:00: Working
_old_0|tes | 2017-07-04 18:01:11 +02:00: Exiting...
0|test     | 2017-07-04 18:01:11 +02:00: Working
0|test     | 2017-07-04 18:01:12 +02:00: Working

@Unitech
Copy link
Owner

Unitech commented Jul 4, 2017

nice catch, just fixed.
Could you try this:

$ npm install Unitech/pm2#development -g
$ pm2 update

@jiripospisil
Copy link
Author

Yep, works. Thanks!

0|test     | 2017-07-04 20:04:19 +02:00: Working
0|test     | 2017-07-04 20:04:19 +02:00: Started
_old_0|tes | 2017-07-04 20:04:20 +02:00: Working
_old_0|tes | 2017-07-04 20:04:21 +02:00: Working
_old_0|tes | 2017-07-04 20:04:22 +02:00: Working
_old_0|tes | 2017-07-04 20:04:23 +02:00: Working
_old_0|tes | 2017-07-04 20:04:24 +02:00: Working
0|test     | 2017-07-04 20:04:24 +02:00: Ready
_old_0|tes | 2017-07-04 20:04:24 +02:00: Received SIGINT, exiting in 5 seconds
0|test     | 2017-07-04 20:04:25 +02:00: Working
0|test     | 2017-07-04 20:04:26 +02:00: Working
0|test     | 2017-07-04 20:04:27 +02:00: Working
0|test     | 2017-07-04 20:04:28 +02:00: Working
0|test     | 2017-07-04 20:04:29 +02:00: Working
_old_0|tes | 2017-07-04 20:04:29 +02:00: Exiting...
0|test     | 2017-07-04 20:04:30 +02:00: Working

@Unitech
Copy link
Owner

Unitech commented Jul 4, 2017

great, reopening and adding the label pending release

@Unitech Unitech reopened this Jul 4, 2017
Unitech added a commit that referenced this issue Jul 4, 2017
@Unitech
Copy link
Owner

Unitech commented Jul 20, 2017

Published on PM2 2.6.0:

$ npm install pm2@latest -g
$ pm2 update

@Unitech Unitech closed this as completed Jul 20, 2017
inerc pushed a commit to inerc/pm2 that referenced this issue Feb 11, 2020
inerc pushed a commit to inerc/pm2 that referenced this issue Feb 11, 2020
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

2 participants