Permalink
Browse files

Use rocco-style docs for MoonshineSetupManifest.rb

  • Loading branch information...
1 parent a1436e5 commit 6ad79f8fcac7c8af95a1a772e7532bc27deab874 @technicalpickles technicalpickles committed Apr 19, 2011
Showing with 24 additions and 16 deletions.
  1. +24 −16 lib/moonshine_setup_manifest.rb
@@ -1,39 +1,46 @@
-# Running <tt>cap deploy:setup</tt> or <tt>cap moonshine:bootstrap</tt>
-# in uploads your <tt>config/moonshine.yml</tt> to <tt>/tmp/moonshine.yml</tt>
-# on your server and applies this manifest.
+# The MoonshineSetupManifest is applied to the server during `cap deploy:setup`.
+# It's responsible for preparing the server to being released to.
+# Specifically, it sets up directories that capistrano will use during `cap deploy`.
#
-# Requires these three variables in a YAML <tt>config/moonshine.yml</tt>:
-#
-# application: your_app_name
-# user: rails
-# deploy_to: /srv/your_app_name
class MoonshineSetupManifest < ShadowPuppet::Manifest
- deploy_stage = ENV['DEPLOY_STAGE'] || 'undefined'
-
+ # Before applying this manifest, `cap deploy:setup` handles uploading the `config/moonshine.yml` so we can load it here.
configure(YAML.load_file('/tmp/moonshine.yml'))
+
+ # If a stage-specific moonshine.yml (ie config/moonshine/staging.yml) is available, it will also be uploaded and loaded here.
+ deploy_stage = ENV['DEPLOY_STAGE'] || 'undefined'
if File.exist? "/tmp/moonshine/#{deploy_stage}.yml"
configure(YAML.load_file("/tmp/moonshine/#{deploy_stage}.yml"))
end
- recipe :directories
-
- # TODO: replicate bin/bootstrap.sh here for 100% idempotency
+ ## Prerequites
+ #
+ # The following configuration is required, either in `config/moonshine.yml` or `config/moonshine/<stage>.yml`:
+ #
+ # :user: rails
+ # :deploy_to: /srv/your_app_name
- # Essentially replicates the deploy:setup command from capistrano, but sets
- # up permissions correctly
+ ## Recipes
+ #
+ ### Directories
+ #
+ # Essentially replicates the deploy:setup command from capistrano, but sets up permissions correctly
def directories
+ # First, the `deploy_to` directory is created, along with its parents
deploy_to_array = configuration[:deploy_to].split('/')
deploy_to_array.each_with_index do |dir, index|
next if index == 0 || index >= (deploy_to_array.size-1)
file '/'+deploy_to_array[1..index].join('/'), :ensure => :directory
end
+
dirs = [
"#{configuration[:deploy_to]}",
"#{configuration[:deploy_to]}/shared",
"#{configuration[:deploy_to]}/shared/config",
"#{configuration[:deploy_to]}/releases"
]
+
+ # Then each of the required directories is created so the `user` can successfully `cap deploy`
dirs.each do |dir|
file dir,
:ensure => :directory,
@@ -42,4 +49,5 @@ def directories
:mode => '775'
end
end
-end
+ recipe :directories
+end

0 comments on commit 6ad79f8

Please sign in to comment.