<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Hank Beaver &#187; rake</title>
	<atom:link href="http://www.hankbeaver.com/index.php/tag/rake/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hankbeaver.com</link>
	<description>Ruby, open-source, Internet technologist located in Atlanta, GA, USA</description>
	<lastBuildDate>Tue, 29 Jun 2010 05:34:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Varnish cache purge Rake task</title>
		<link>http://www.hankbeaver.com/index.php/2009/07/15/varnish-cache-purge-rake-task/</link>
		<comments>http://www.hankbeaver.com/index.php/2009/07/15/varnish-cache-purge-rake-task/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 02:28:24 +0000</pubDate>
		<dc:creator>hbeaver</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[varnish]]></category>
		<category><![CDATA[purge]]></category>
		<category><![CDATA[rake]]></category>
		<category><![CDATA[task]]></category>

		<guid isPermaLink="false">http://www.rubyslacker.com/?p=93</guid>
		<description><![CDATA[This example uses Ruby to telnet into Varnish and issue the &#8220;url.purge .*&#8221; command. The only gotcha is that the varnish telnet server does not issue a command prompt which causes Ruby telnet to timeout and get cranky. Well a little exception handling hacks past this. Enjoy.

require 'rubygems'

namespace "varnish" do

  desc "Purge ALL urls [...]]]></description>
			<content:encoded><![CDATA[<p>This example uses Ruby to telnet into Varnish and issue the &#8220;url.purge .*&#8221; command. The only gotcha is that the varnish telnet server does not issue a command prompt which causes Ruby telnet to timeout and get cranky. Well a little exception handling hacks past this. Enjoy.</p>
<pre>
require 'rubygems'

namespace "varnish" do

  desc "Purge ALL urls from Varnish"
  task :global_purge => :environment do

    #It WILL timeout, just accept it. Varnish does not have a command prompt.
    require 'net/telnet'
    @result = ""
    begin
      localhost = Net::Telnet::new("Host" => "localhost",
      "Port" => 6082,
      "Timeout" => 5)
      localhost.cmd("url.purge .*") { |c| @result = c}
    rescue Exception
      if @result.include? ("200 0")
        puts "varnish purged OK."
      else
        raise "Varnish not purged."
      end
    end
  end

end
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.hankbeaver.com/index.php/2009/07/15/varnish-cache-purge-rake-task/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
