AWS OpsWorks

First a bit about AWS OpsWorks, it's Amazon's answer to operating your own datacenter.  With OpsWorks you can do things like easily autoscale your systems by time or load, deploy your applications from Github (or S3), monitor your stack with Ganglia, and a whole raft of other things.

Stacks

The OpsWorks architecture is designed in what they call "stacks".  These stacks are just groups of components that work together to do whatever task you want them to do (i.e. provide a web service of some kind).  The stack is broken up into layers with each layer having a unique job within the stack (load balancer, app server, DB server, etc.)  

Rails (Rack) Layer

The layer I'm concerned with in this post is the application server layer.  There are several different types of apps that are supported out of the box; PHP, Rails, Node, and static HTML.  I wanted to run a Ruby Sinatra application, which is close to a Rails app, but not quite.  It turns out that the "Rails" layer is actually a "Rack" application and natively supports anything that runs under Rack, such as Sinatra.  :)

All you have to do to get your Rack application running in OpsWare is create these three files in your project and deploy your application just like normal.  :)

#Gemfile
=============================
source 'https://rubygems.org'

gem 'sinatra'
gem 'unicorn'

=============================

#app.rb
=============================
require 'rubygems'
require 'sinatra'

get '/' do
"hello world!"
end
=============================

# config.ru
=============================
require 'sinatra'

set :env, :production
disable :run

require './app.rb'

run Sinatra::Application
=============================