|
Articles tagged capistrano
Jeffrey Allan Hardy has written a guide about how to deploy public gems. Now what if you have your own private gems, and you like to deploy them as easily as deploying a rails app, what do you do? Use capistrano. This articles shows how to use Capistrano to deploy your own private gem.
You gem should have existing tasks called "gem" and "install_gem", you can get them automatically if you use new_gem to generate your new gem (that's a mouthful). On another thought, new_gem should be renamed to "gem_gen", sounds alot cooler and less confusing. 1. Write cap tasksin your gem project folder, create 2 files, "capfile", and "gem_deploy.rb".capfile should be looks like this: load 'deploy' if respond_to?(:namespace) # cap2 differentiator
load 'gem_deploy'and gem_deploy.rb should have following # to deploy this gem, check out first, then
#
# cap deploy:setup
# cap deploy:update_code
#
#
# === reference ===
# install standard gem
# http://www.quotedprintable.com/2007/3/16/installing-gems-with-capistrano
#ssh_options[:verbose] = :debug
set :synchronous_connect, true # without this, upload task will hang
role :lib, "mysite.com"
set :application, "my_cool_gem"
set :repository, "svn://my/gems/#{application}/trunk"
set :deploy_to, "/home/dorren/temp/#{application}"
set :user, "dorren"
set :deploy_via, :copy
namespace :deploy do
desc "build and install gem by using rake"
task :finalize_update do
# -S accepts password from stdin instead of terminal, see man sudo"
cmd = "-S ls && cd #{current_release} && rake gem && rake install_gem"
sudo cmd do |channel, stream, data|
print data if stream == :out
channel.send_data($stdin.gets) if data =~ /^>\s/
end
end
end
2. Deploycap deploy:setupwill setup temporary staging folder.cap deploy:update_code will install the gem.3. troubleshootingQ: I get error, "<me> is not in the sudoers file." when deploying.A: I just added myself into the sudoer group which resolved the problem.
Views: 1682
Replies: 0
Tags:
capistrano,
gem
|
login or sign up
to participate.
Tags
moneywill |
|||||||||||||||||||||||||||||||