Skip to content

ricodigo/ricodigo-capistrano-recipes

Repository files navigation

Capistrano Recipes

Useful Capistrano recipes including:

  • Create Mongoid database and user on server (via prompts)

  • Create standalone copy of mongoid.yml in shared path (via prompts)

  • Log rotation and tailing commands

  • Configure, start/stop/restart Unicorn application server

  • Send commands to Bluepill monitoring tools

Included Tasks

  • cap db:create_yaml

  • cap db:mongoid:setup

  • cap db:mongoid:dump

  • cap db:mongoid:fetch_dump

  • cap db:mongoid:restore

  • cap log:rotate

  • cap log:tail

  • cap nginx:setup

  • cap nginx:start

  • cap nginx:stop

  • cap nginx:restart

  • cap nginx:status

  • cap unicorn:start

  • cap unicorn:stop

  • cap unicorn:restart

  • cap unicorn:setup

  • cap symlinks:make

  • cap bluepill:install

  • cap bluepill:init

  • cap bluepill:start

  • cap bluepill:restart

  • cap bluepill:stop

  • cap bluepill:status

Installation

Easy as pie…

Install this gem:

sudo gem install ricodigo-capistrano-recipes

To setup the initial Capistrano deploy file, go to your Rails app folder via command line and enter:

capify .

Configuration

Inside the newly created config/deploy.rb, add:

require 'capistrano/ext/multistage' # only require if you've installed Cap ext gem

# This one should go at the end of your deploy.rb
require 'ricodigo_capistrano_recipes'

RVM

RVM is enabled by default. You can disable it by setting :using_rvm to false, or leverage it by setting your rvm_ruby_string to appropriate ones (default is ree)

If using_rvm is true, the rvm recipe will load rvm’s own capistrano extensions so you don’t have to worry about it during deploy. Just make sure you have everything set up right, like .rvmrc on project root and system-wide install on the servers.

See (rvm.beginrescueend.com/rvm/install) for more info.

Nginx

If you’re using nginx as your web server, set :web_server to :nginx and deploy:setup will generate the appropriate configuration file for it based on your other variables, such as :application_uses_ssl, etc.

Unicorn

If you’re running Unicorn (unicorn.bogomips.org/) be sure to add this line instead:

set :server, :unicorn

Contributors (thank you!)

github.com/ricodigo/ricodigo-capistrano-recipes/contributors

Copyright © 2009-2011 Webficient LLC, Phil Misiowiec. See LICENSE for details.