Every repository with this icon (
Every repository with this icon (
Getting Rails in the pool
Let’s get a fully-automated, scalable rails web application in the pool.
First, let’s generate the rails app
rails poolparty_app
Keeping my directories together:
cd poolparty_app
Now, build your app… I can wait…
Ready? Now edit the pool.spec to add rails… Sample rails setup:
pool :clouds do
cloud :app do
instances 2..3
has_directory “/var/www”
has_git_repos “my_app” do
at “/var/www”
source “git://github.com/auser/my_app.git”
owner “www-data”
end
chef do
include_recipes “~/.poolparty/chef/cookbooks/*”
recipe “/Users/alerner/.poolparty/chef_recipe.rb”
templates “/Users/alerner/.poolparty/templates/”
end
end
end
Note that we are using chef recipes. A chef tutorial is out of scope for this tutorial, but the chef recipe that we are using here looks like:
include_recipe "apache2"
include_recipe "passenger"
node[:rails][:version] = "2.3.2"
include_recipe "rails"
web_app "paparazzi" do
docroot "/var/www/paparazzi/public"
template "paparazzi.conf.erb"
server_name "www.paparazzi.com"
server_aliases [node[:hostname], node[:fqdn], "paparazzi.com"]
rails_env "production"
end
Note that this references a template called “paparazzi.conf.erb.” That looks like this
<VirtualHost *:8080>
ServerName <%= @params[:server_name] %>
ServerAlias <% @params[:server_aliases].each do |a| %><%= "#{a}" %> <% end %>
DocumentRoot <%= @params[:docroot] %>
RailsBaseURI /
RailsEnv <%= @params[:rails_env] %>
RailsAllowModRewrite on
PassengerMaxPoolSize <%= @node[:rails][:max_pool_size] %>
<Directory <%= @params[:docroot] %>>
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
LogLevel info
ErrorLog <%= @node[:apache][:log_dir] %>/<%= @params[:name] %>-error.log
CustomLog <%= @node[:apache][:log_dir] %>/<%= @params[:name] %>-access.log combined
</VirtualHost>
Full gist here: http://gist.github.com/25097
Note, this is a chef recipe, so check out the chef tutorials here: http://wiki.opscode.com/
For the time being, we won’t worry about the database-side of the app as we’ll get to that in another tutorial.
Now, let’s go into the clouds directory RAILS_ROOT:
cloud start
Now your cloud is starting up. Depending on your setup, this process can take up to 10 minutes







