Skip to content

Instantly share code, notes, and snippets.

View auser's full-sized avatar

Ari auser

View GitHub Profile
## That's one way...
# Think we can make this less ruby-specific?
solution :myapp do
cloud :db do
mysql :master => 1, :max_slaves => 4
end
cloud :web do
rails ...
solution :myapp do
cloud :db do
mysql :master => 1, :max_slaves => 4
end
cloud :web do
rails ...
nginx ...
end
pool :poolpartyrb do
plugin_directory "plugins"
cloud :app do
# Configuration
configure { :maximum_instances => 1,:keypair => "name" }
minimum_instances 1
apache do
class Doc
def method_missing(m, *args, &block)
args.empty? ? options[m] : options[m] = args[0]
end
def options
@options ||= {}
end
def initialize(&block)
self.instance_eval(&block) if block_given?
end
module MethodMissingSuga
def method_missing(m, *args, &block)
args[0].instance_eval(&block) if block
args.empty? ? options[m] : options[m] = args[0]
end
def options
@options ||= {}
end
def initialize(&block)
self.instance_eval(&block) if block
class Image
attr_reader :src
def self.zoom_crop(src, max_width, max_height, out="thumbs/")
# Image details
new(src).zoom_crop(max_width, max_height, out)
end
def initialize(src)
@src = src
end
## Basic.rb
# Basic pool spec
# Shows global settings for the clouds
# Notice, the clouds take the options set by the cloud
pool :app do
instances 3..5
cloud :app do
pool :app do
plugin_directory File.join(File.dirname(__FILE__), "plugins")
instances 2..10
cloud :app do
apache do
enable_php
end
module Slicehost
# the 4 methods (may add a few more)
# that are required for an extra base
def instances_list
...
end
register_remote_base :slicehost
end
apache do
installed_as_worker
listen("8080")
has_virtualhost do
name "xnot.org"
template ::File.join(File.dirname(__FILE__), "cb/templates", "virtual_host.conf.erb")
has_file(:name => "/var/www/xnot.org/public/index.html") do
template ::File.join(File.dirname(__FILE__), "cb/templates", "index.html")