I seem to have to send the 'ready' message twice in conjunction with the wait-ready flag, else it waits until listen-timeout is reached.
pm2 start build/server/main.js --name myapp -i 2 --wait-ready --listen-timeout 20000
pm2 reload myapp --parallel 1
In main.ts
nodeServer = server.listen(config.port, function(){
console.log('Server running on port ' + config.port);
//Notify pm2 that the instance is ready to accept connections
if(process.send){
//Due to a bug, we have to send this twice
process.send('ready');
process.send('ready');
}
});
Sending the message twice as above works, whereas sending it once causes listen-timeout to be reached.
Using pm2 3.5 and node 11.12.
@benstevens48 dude, how did you figure this out?! I have been struggling with this bug for almost a year now! Thank you for posting this issue and workaround. I owe you one.
Wut this need to be fixed
https://github.com/Unitech/pm2/blob/master/lib/God/Reload.js#L140
@benstevens48 dude, how did you figure this out?! I have been struggling with this bug for almost a year now! Thank you for posting this issue and workaround. I owe you one.
I thought it might be a timing issue so put process.send('ready') in various places in my startup code without removing the original process.send('ready') and it worked wherever I put it, but when I removed the original statement it stopped working - so eventually came to this conclusion.
I think it is quite old issue. How is it going?
@Unitech, @sharpart555, @benstevens48 I have this issue and made PR with fix
https://github.com/Unitech/pm2/pull/4376
merged, will land on [email protected]
Available in PM2 4.1.0
npm install pm2@latest -g
pm2 update