Resetting a 503-ed Openshift Ruby on Rails container using RHC

Posted in software by Christopher R. Wirz on Wed Jan 13 2016

Due to a long standing bug with InnoDB in MySQL, disk space on the database container may be exhausted and it's time to attach a new container to your application. This is particularly a problem on OpenShift running Ruby on Rails where the container uses InnoDB by default and the space on the gear is limited. Ruby on Rails has a notorious small session size, and so many developers like to store session information in the database. While this may be common practice, the repeated write operations create un-managed temporary files that will ultimately fill the available disk space. So, it's good to have a separate MySQL container for the session management. This usually results in a 503 or 500 error for your Ruby on Rails application.

If you haven't already, you need to install the rhc client. After RHC is installed, your application can be fixed from the terminal.

First, see the containers/gears associated with your application (we assume the application name to be "ruby").

rhc app show ruby

After verifying the inoperable MySQL instance, remove it.

rhc cartridge remove mysql-5.5 -a ruby

Since Ruby on Rails requires MySQL, it needs to be added back.

rhc cartridge add mysql-5.5 -a ruby

Now it's time to reset the gear.

rhc app tidy -a ruby
rhc app force-stop -a ruby
rhc app reload -a ruby
rhc app start -a ruby

The final step is to perform a commit to the container's git instance. This will activate the git hook to rebuild the record set.

touch *.rb
git add .
git commit -m "Just resetting the container"
git push -f

Your application should be back up and running.

Looking for a job?