Tuesday, September 04
And now for something new. Links for today. Whatever. It’s new to me.
- Has finder: a new ActiveRecord extension that makes it easier than ever to create custom find and count queries. Looks better than both of scope-out and scoped-proxy.
- Zooom: window stuff for OS X. Done right.
- Webistrano: a web front-end for Capistrano.
- Seesaw: high-availability Mongrel Packs.
- Sphincter: ActiveRecord extension for full-text searching with Sphinx.
Monday, July 23
This is cool. The newest version of Capistrano now supports multiple stages. Like when you want to have different configuration for, say, production, testing, and staging. This is something I’ve been doing manually, which while it works, is not without its quirks.
It’s part of the capistrano extensions plugin (capistrano-ext), which is as easy as gem install capistrano-ext to obtain. Once installed, you simply require the multistage support in your deploy recipe file.
require 'capistrano/ext/multistage'
The best part is how stages are defined. All you have to do is place your stage-specific code in config/deploy/staging.rb and/or
config/deploy/production.rb and it will get loaded automatically.
And if your stages aren’t named “production” and “staging,” you can define your own easily. You can then deploy to the staging server with cap staging deploy and to the production server with cap production deploy. And if you want the stating server to be the default, you can save yourself some typing by setting the default stage:
set :default_stage, 'staging'
require 'capistrano/ext/multistage'
For the full announcement, see Jamis Buck’s blog.
Friday, March 16
Ever go to deploy a copy of your application and realize that you don’t have all the required gems installed? This is what I do to handle such a precarious situation via capistrano.
desc 'Installs required gems for this application'
task :install_gems, :roles => :app do
# Add all gems required by your application here
gems = %w(
aws-s3
libxml-ruby
redcloth
tzinfo
)
sudo "gem install -y --no-rdoc --no-ri #{gems.join(' ')}" do |channel, stream, data|
print data if stream == :out
channel.send_data($stdin.gets) if data =~ /^>\s/
end
end
The channel.send bit is so you can respond to gems that have multiple versions available (i.e., mongrel). I’m also skipping rdoc and ri for this since I generally don’t care about having the documentation on the production server and it’s a bit faster when you skip them.
Oh, and if you wanted this to happen automatically after your cap setup, you could invoke it using (wait for it) the after_setup callback.
I’m sure there are improvements that could be made to this code, so suggestions are welcome.