<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: capistrano code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Wed, 20 Aug 2008 09:42:12 GMT</pubDate>
    <description>DZone Snippets: capistrano code</description>
    <item>
      <title>Upgrade rubygems and/or specific gems themselves via capistrano</title>
      <link>http://snippets.dzone.com/posts/show/4905</link>
      <description>When a latest RubyGems is released (e.g. 0.9.5 recently) or Rails (e.g. 2.0.2) you might want to push those upgrades to all your production machines.&lt;br /&gt;&lt;br /&gt;Add these two tasks to your deploy.rb capistrano file (add namespaces for cap2.0 if you like)&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;  desc "Updates RubyGems version"&lt;br /&gt;  task :gem_update_system do&lt;br /&gt;    sudo "gem update --system"&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;    &lt;br /&gt;  desc "Install a RubyGem from remote source"&lt;br /&gt;  task :gem_install do&lt;br /&gt;    puts "USAGE: GEM=gemname cap gems_install" and next unless ENV['GEM']&lt;br /&gt;    sudo "gem install #{ENV['GEM']} --no-ri --no-rdoc"&lt;br /&gt;  end&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;To upgrade rubygems and rails, for example:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;cap gem_update_system&lt;br /&gt;GEM=rails cap gem_install&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;</description>
      <pubDate>Wed, 19 Dec 2007 22:10:32 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4905</guid>
      <author>nicwilliams (Dr Nic Williams)</author>
    </item>
    <item>
      <title>Dump postgres production data into development database</title>
      <link>http://snippets.dzone.com/posts/show/3958</link>
      <description>When bug requests come in, its great to grab a copy of the current production (or system test env) data and sync it into your development database.&lt;br /&gt;&lt;br /&gt;Here's a capistrano recipe for postgresql:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;desc "Dumps target database into development db"&lt;br /&gt;task :sync_db do&lt;br /&gt;  env   = ENV['RAILS_ENV'] || ENV['DB'] || 'production'&lt;br /&gt;  file  = "#{application}.sql.bz2"&lt;br /&gt;  remote_file = "#{shared}/log/#{file}"&lt;br /&gt;  run "pg_dump --clean --no-owner --no-privileges -U#{db_user} -h#{db_host} #{db_name}_#{env} | bzip2 &gt; #{file}" do |ch, stream, out|&lt;br /&gt;    ch.send_data "#{db_password}\n" if out =~ /^Password:/&lt;br /&gt;    puts out&lt;br /&gt;  end&lt;br /&gt;  puts rsync = "rsync #{user}@#{domain}:#{file} tmp"&lt;br /&gt;  `#{rsync}`&lt;br /&gt;  puts depackage = "bzcat tmp/#{file} | psql #{local_db_dev}"&lt;br /&gt;  `#{depackage}`&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 06 May 2007 09:00:17 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3958</guid>
      <author>nicwilliams (Dr Nic Williams)</author>
    </item>
    <item>
      <title>Capistrano logs</title>
      <link>http://snippets.dzone.com/posts/show/3794</link>
      <description>To get the last n lines from a remote log file, use this task&lt;br /&gt;&lt;br /&gt;Usage: cap log [-s lines=100] [-s rails_env=production]&lt;br /&gt;So, "cap log" returns 100 lines from production.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;desc "Returns last lines of log file. Usage: cap log [-s lines=100] [-s rails_env=production]"&lt;br /&gt;task :log do&lt;br /&gt;  lines     = configuration.variables[:lines] || 100&lt;br /&gt;  rails_env = configuration.variables[:rails_env] || 'production'&lt;br /&gt;  run "tail -n #{lines} #{app_dir}/log/#{rails_env}.log" do |ch, stream, out|&lt;br /&gt;    puts out&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 10 Apr 2007 20:09:05 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3794</guid>
      <author>nicwilliams (Dr Nic Williams)</author>
    </item>
  </channel>
</rss>
