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.

  • Kubernetes Redis HA and exposing redis to things outside of the container
  • X11 forwarding with PyCharm and Docker Interpreter
  • Bash command to return a free port
  • consumer: Cannot connect to amqp://user:**@localhost:5672//: [Errno 111] Connection refused
  • Docker: how to to get access to interactive mode once server started in foreground?
  • Wrappers for Auto creation of VM in cloud providers
  • 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?

  • Import images from kitematic to boot2docker
  • How to mimic “--log-driver=syslog” in Kubernetes
  • Error running openshift/origin docker: Error running 'chcon' to set the kubelet volume root directory SELinux context
  • Security of Docker as it runs as root user
  • Docker aufs and devicemapper directories both exist
  • Are default cronjobs executed in a docker?
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.