<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3639259744194713693</id><updated>2011-11-27T18:58:14.951-05:00</updated><category term='ruby'/><category term='god'/><category term='intellum'/><category term='monitoring'/><category term='rails'/><category term='backgroundrb'/><title type='text'>Two Minute Spates</title><subtitle type='html'>Another innocuous, sometimes helpful, programmer blog.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://robotpoke.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3639259744194713693/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://robotpoke.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Jonathan Wallace</name><uri>http://www.blogger.com/profile/15904469216670512994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3639259744194713693.post-6291871937533859033</id><published>2009-03-08T13:20:00.002-05:00</published><updated>2009-03-08T13:21:54.946-05:00</updated><title type='text'></title><content type='html'>This blog has moved to &lt;a href="http://blog.jonathanrwallace.com"&gt;http://blog.jonathanrwallace.com&lt;/a&gt;.  From this point forward, all new content is posted there.  Thanks.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3639259744194713693-6291871937533859033?l=robotpoke.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://robotpoke.blogspot.com/feeds/6291871937533859033/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3639259744194713693&amp;postID=6291871937533859033' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3639259744194713693/posts/default/6291871937533859033'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3639259744194713693/posts/default/6291871937533859033'/><link rel='alternate' type='text/html' href='http://robotpoke.blogspot.com/2009/03/this-blog-has-moved-to-httpblog.html' title=''/><author><name>Jonathan Wallace</name><uri>http://www.blogger.com/profile/15904469216670512994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3639259744194713693.post-7259702373442398240</id><published>2008-08-14T12:04:00.014-05:00</published><updated>2008-09-24T09:03:58.586-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='backgroundrb'/><category scheme='http://www.blogger.com/atom/ns#' term='god'/><category scheme='http://www.blogger.com/atom/ns#' term='rails'/><category scheme='http://www.blogger.com/atom/ns#' term='monitoring'/><category scheme='http://www.blogger.com/atom/ns#' term='intellum'/><title type='text'>Monitoring BackgrounDRb workers with God</title><content type='html'>&lt;span style="font-style:italic;"&gt;Updated 2008/09/24 for latest version of backgroundrb 1.0.4&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The other day on our staging server, I noticed that the &lt;a href="http://backgroundrb.rubyforge.org/"&gt;BackgrounDRb&lt;/a&gt; queue worker had died.  As it turned out, the queue worker had died over 3 months ago!!&lt;br /&gt;&lt;br /&gt;There was no cause for alarm as the staging server isn't critical but this did start me to worrying.  We needed to implement a monitoring solution which not only verified that BackgrounDRb was running but also that particular workers were running.&lt;br /&gt;&lt;br /&gt;As we had just implemented &lt;a href="http://god.rubyforge.org/"&gt;god&lt;/a&gt; monitoring with a custom condition for another issue, its a slam dunk to do the same again.  (Thanks to &lt;a href="http://jnewland.com/"&gt;Jesse Newland&lt;/a&gt; and his &lt;a href="http://atlrug.org/jnewland/posts/45-God-Process-and-Task-Monitoring-Done-Right-Slides"&gt;god tutorial&lt;/a&gt; at &lt;a href="http://atlrug.org/"&gt;AtlRUG&lt;/a&gt;.)&lt;br /&gt;&lt;br /&gt;Here's the configuration file that got it done for us. &lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;  1 #run on command line with 'god -c backgroundrb.god -D'&lt;br /&gt;  2 RAILS_ROOT = '/var/www/rails/rollbook/current'&lt;br /&gt;  3 &lt;br /&gt;  4 #load required rails and backgroundrb files&lt;br /&gt;  5 require File.dirname(__FILE__) + '/../boot'&lt;br /&gt;  6 require File.dirname(__FILE__) + '/../environment'&lt;br /&gt;  7 require 'erb'&lt;br /&gt;  8 $LOAD_PATH &lt;&lt; "#{RAILS_ROOT}/vendor/plugins/backgroundrb/lib"&lt;br /&gt;  9 require "#{RAILS_ROOT}/vendor/plugins/backgroundrb/lib/backgroundrb.rb"&lt;br /&gt; 10 &lt;br /&gt; 11 #create custom condition for checking that QueryProcessingWorker is running&lt;br /&gt; 12 MiddleMan = BackgrounDRb::ClusterConnection.new&lt;br /&gt; 13 module God&lt;br /&gt; 14   module Conditions&lt;br /&gt; 15     class Backgroundrb &lt; PollCondition&lt;br /&gt; 16       def initialize; super; end&lt;br /&gt; 17       def valid?; true; end&lt;br /&gt; 18 &lt;br /&gt; 19       def test&lt;br /&gt; 20         begin&lt;br /&gt; 21           queue_worker = MiddleMan.all_worker_info.values.flatten.select { |w| :queue_processing_worker == w[:worker] }&lt;br /&gt; 22           queue_worker.empty?&lt;br /&gt; 23         rescue #if all_worker_info raises exception, then bdrb isn't running and we were unable to connect&lt;br /&gt; 24           true&lt;br /&gt; 25         end&lt;br /&gt; 26       end&lt;br /&gt; 27     end&lt;br /&gt; 28   end&lt;br /&gt; 29 end&lt;br /&gt; 30 &lt;br /&gt; 31 God.watch do |w|&lt;br /&gt; 32   w.name      = 'backgroundrb'&lt;br /&gt; 33   w.interval  = 1.minute&lt;br /&gt; 34   w.restart   = "cd #{RAILS_ROOT} &amp;&amp; #{RAILS_ROOT}/script/backgroundrb -e production stop &amp;&amp; #{RAILS_ROOT}/script/backgroundrb -e production start"&lt;br /&gt; 35   w.stop      = "cd #{RAILS_ROOT} &amp;&amp; #{RAILS_ROOT}/script/backgroundrb -e production stop"&lt;br /&gt; 36   w.start     = "cd #{RAILS_ROOT} &amp;&amp; #{RAILS_ROOT}/script/backgroundrb -e production start"&lt;br /&gt; 37   w.grace     = 1.minute&lt;br /&gt; 38   w.pid_file  = "#{RAILS_ROOT}/tmp/pids/backgroundrb_11000.pid"&lt;br /&gt; 39 &lt;br /&gt; 40   w.start_if do |start|&lt;br /&gt; 41     start.condition(:process_running) do |c|&lt;br /&gt; 42       c.running  = false&lt;br /&gt; 43     end&lt;br /&gt; 44   end&lt;br /&gt; 45 &lt;br /&gt; 46   w.restart_if do |restart|&lt;br /&gt; 47     restart.condition(:backgroundrb) do |c|&lt;br /&gt; 48       #just restart it&lt;br /&gt; 49     end&lt;br /&gt; 50   end&lt;br /&gt; 51 end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In the select call on line 21, you can modify the condition to access :job_key or :status as well.  Obviously, you need to modify RAILS_ROOT for your situation.&lt;br /&gt;&lt;br /&gt;If you have suggestions for improvement or questions, hit me up in the comments.  Enjoy!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3639259744194713693-7259702373442398240?l=robotpoke.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://robotpoke.blogspot.com/feeds/7259702373442398240/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3639259744194713693&amp;postID=7259702373442398240' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3639259744194713693/posts/default/7259702373442398240'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3639259744194713693/posts/default/7259702373442398240'/><link rel='alternate' type='text/html' href='http://robotpoke.blogspot.com/2008/08/monitoring-backgroundrb-workers-with.html' title='Monitoring BackgrounDRb workers with God'/><author><name>Jonathan Wallace</name><uri>http://www.blogger.com/profile/15904469216670512994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3639259744194713693.post-8662127713039308698</id><published>2007-12-28T15:58:00.000-05:00</published><updated>2007-12-28T16:18:33.103-05:00</updated><title type='text'>Ack, a better grep for coders in 3 easy steps</title><content type='html'>&lt;a href="http://petdance.com/ack/"&gt;Ack&lt;/a&gt; has this nice colorized output when searching code files.  Some may say that grep can do the same thing (it can), but there's no need for arg'ing it up with ack.  There's a similar ruby version, &lt;a href="http://rak.rubyforge.org/"&gt;rak&lt;/a&gt;, but I've heard it isn't quite as fast as ack.  Ack works well enough for me and the install process isn't that painful.&lt;br /&gt;&lt;br /&gt;There's two ways to install listed over at &lt;a href="http://petdance.com/ack/"&gt;ack&lt;/a&gt;; I chose the CPAN route (since I never know when I'll need to install some more perl goodies).&lt;br /&gt;&lt;br /&gt;How to install ack on Mac OS X leopard in 3 easy steps.&lt;br /&gt;&lt;ol&gt;&lt;li&gt;install &lt;a href="http://www.macports.org/"&gt;mac ports&lt;/a&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;sudo port install perl5.8&lt;/li&gt;&lt;li&gt;sudo cpan -i App::Ack&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3639259744194713693-8662127713039308698?l=robotpoke.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://robotpoke.blogspot.com/feeds/8662127713039308698/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3639259744194713693&amp;postID=8662127713039308698' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3639259744194713693/posts/default/8662127713039308698'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3639259744194713693/posts/default/8662127713039308698'/><link rel='alternate' type='text/html' href='http://robotpoke.blogspot.com/2007/12/ack-better-grep-for-coders-in-3-easy.html' title='Ack, a better grep for coders in 3 easy steps'/><author><name>Jonathan Wallace</name><uri>http://www.blogger.com/profile/15904469216670512994</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
