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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Send a 'ready' message to parent process if api server was spawned #4744
Conversation
This enabled zero-downtime restarts for the API server with pm2. See https://pm2.keymetrics.io/docs/usage/signals-clean-restart/#graceful-start
Hey Rob, nice one! I wonder if its worth adding to the other handlers as well? |
Ahh good call, in case you're serving web or both! On it... |
Maybe would be cleaner with just |
Or even |
I was gonna say... but didn't want to be a pedant! I like this better Maybe even have it in a function? |
Oooo what's a good name? |
Yep sounds good! Other options: |
Voil脿! |
This enables zero-downtime restarts for the API server with pm2. See https://pm2.keymetrics.io/docs/usage/signals-clean-restart/#graceful-start
process.send
will only exist if the process was spawned from a parent, so we need to check if it is defined (which it is when pm2 is in control). There is no "api server" in serverless environments so this code should have no effect there.We'll also want to document the fact somewhere that you need to add two things to your
ecosystem.config.js
for pm2:wait_ready
tells it to actually listen for that message. The default timeout is 3 seconds which is not enough for the API server to start. Here it's increased to 10 seconds.This was tested in Algostake and works like a charm! Previous there was 2-3 seconds of downtime each time the API server was restarted on a deploy. Now it's seamless!
I'd love to include the BAREMETAL deploy option by the v1.0 deadline but I've got a lot of stuff that still needs to get done before then! 馃槵