Graceful shutdown

I’m working on a parse-server node backend application that is running with PM2 (process manager for node). I would like to know what is the best practice to achieve a graceful shutdown of the parse-server application because I don’t want to shut the app down in the middle of a query or any unfinished job.

Here is what PM2 says about graceful shutdown

Thanks for your help !

+1. I wonder how we reload/stop parse server without interrupting current operations.

I’d recommend to have a reverse proxy on top of parse server. You first set the proxy to stop forwarding requests to the parse server process. You wait the process to drain and then stop.

1 Like

That makes sense…

Hello @davimacedo, thanks for your answer!

I have an apache server as proxy with this kind of configuration in my vhost

ProxyPreserveHost On
ProxyRequests Off
ProxyPass / http://localhost:1337/
ProxyPassReverse / http://localhost:1337/

How would you proceed to tell apache to stop forwarding?
Then how do you know that you can stop the process?

It would be great if you can help me documenting the procedure to follow.

Have a nice day!

Hi @Rafarel I don’t have great expertise on apache but probably if you remove the proxypass and reload (not restart) apache, it will stop passing new requests, will still process the current ones, and will finally gracefully restart apache with the new settings. Then you can stop your parse server process.