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.

Question

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.

  • mounting local home directory in Rstudio docker?
  • Docker build npm error logs
  • Is it possible to view docker-compose logs in the output window running in Windows?
  • How can write Dockerfile to start a webserver and curl it for some requirements
  • Docker-machine create: Error with pre-create check: “Hyper-v commands have to be run as an Administrator”
  • Docker - how to set up compose for local webserver
  • 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?

  • npm package.json and docker (mounting it…)
  • Pass arguments to parent Dockerfile
  • Docker best practice scaling
  • Unable to launch docker daemon
  • Swarm: Get Node Ip and Container IP from service
  • Dockerfile/npm: create a sudo user to run npm install
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.