Setting up Rails on Digital Ocean with

Lately, I've been having a good time with I've also been enjoying Digital Ocean. Combining the two has caused a couple of problems when it came to Digital Ocean's one-click Rails VPS. Following Digital Ocean's tutorial on how to quickly setup a Rails application, I ran into a few details that weren't mentioned therein that I thought it would be best to share in case someone else has the trouble. 

Nothing that came up was really Dploy's problem, so most of these are on Digital Ocean, but there's a couple additional actions that are useful for updating a Digital Ocean Rails VPS.

Okay - now the problem that started it all: My site just didn't work and hung.

This was an out of the box, totally clean rails installation. I put together one controller to make sure I had routing functioning, but aside from that it was as fresh as it gets. Replacing the default Digital Ocean rails application with mine is where my problems began. Here's how I went about fixing it:

  1. You'll need to make sure you have a secrets.yml file and have generated a key for the production environment. My basic 'rails new' didn't do this on my desktop, but this was present in the default DO installation. You can generate a key using 'rake secret' if you like. In this case, I placed this file as a static file for to override my local file so that the real key wasn't left in source control. 
  2. Your Gemfile needs to include 'mysql2' and 'unicorn' gems. I was having a little trouble locally with the former gem, and so I created a production gemfile that also overwrote after pulling from git. Mysql2 was mentioned in the tutorial, but activating the unicorn gem was not.
  3. Production.log needs to be created with permissions 0666. This does require a unicorn restart. 
  4. As described in the tutorial, you'll also need to set the correct database credentials in your database.yml file. 
  5. Finally, I also added "service unicorn restart" and "RAILS_ENV=production rake db:reset" as post build commands. 

Not end-of-the-world type stuff, but the secrets and missing unicorn gem details were annoying, as was unicorn hanging on a missing production.log file. However, once it's all hooked up, I've got automated deployment, custom config files and hook events running after every commit, which sure does feel nice.