Automatically Stopping/Restarting a Phusion Passenger Docker container

The system

  • 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.

Trouble Shooting

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 pull push not working post successful login
  • Tailing multiple files in a container
  • How to include dependencies in .NET Core app docker image?
  • Docker container bash can't connect to local MySQL server through socket
  • Invalid US-ASCII character using SASS
  • Docker-Tuleap-List all Tuleap database tables running in docker container
  • 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.

    Solution investigation

    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?

  • Kubernetes how to run container only after volume(nfs) is mounted
  • how to stop dockerized nginx in foreground from flooding logs?
  • Does docker stack deploy work with local images
  • Docker Swarm mode - equivalent docker commands to docker run -it ubuntu
  • I found an image on docker hub that I like but doesn't meet my needs. How do I update it and make it my own?
  • Seeding a MySQL DB for a Dockerized Django App
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.