Automatically Stopping/Restarting a Phusion Passenger Docker container
- docker container with our rails app
- using the passenger phusion + nginx image
- Systemd to manages my docker containers (restarts happen if it crashes/is stopped with
docker stop myRailsApp)
- PROBLEM There is a spot in our code that will has a circular reference and queries active record forever.
I’m trying to find a way to make this be handled automatically. My container or app process is stopped and new traffic is served.
Docker process: on
docker restart myRailsApp it restarts but for some reason the queries keep going after the container restart. I have to totally stop the container from restarting to make the queries stop.
Docker stats shows the NET IO stat on the container skyrocket and the CPU goes high, but passenger or nginx don’t seem to kill the query. There are some reasons this may be the case. It’s a response from within the page, i.e. no new page is loaded – it’s something that is clicked after the page is loaded.
Docker: I’ve looked at the healthcheck instruction for docker, maybe by pinging every 20 seconds with a 10 second timeout. This however requires I update my docker on the system, and I don’t even know if it would work.
Is there something in Nginx or passenger that will do the timeout automatically? I’ve looked at the nginx config page and looked at client_body_timeout, and client_header_timeout but the guide seems to say they have a default value of 60 seconds.
These active record calculations didn’t stop after 60 seconds so it seems likely we need a passenger/nginx option. Here is a page at Phusion that is on Stuck Apps, but it says “TODO”.
I’m going to fix the other problem that made this one apparent but this is more serious. If I can fix it, I can feel slightly more secure with unknown issues.
What options do I have, if any?