<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Talk Like A Duck: Tag monit</title>
    <link>http://talklikeaduck.denhaven2.com/articles/tag/monit</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>In Ruby, it's not the dog, it's the tricks!</description>
    <item>
      <title>Keeping it up (Your Rails App that is)</title>
      <description>&lt;p&gt;&lt;img src="http://talklikeaduck.denhaven2.com/files/128x144px-Tiziano_-_S%C3%ADsifo.png"  style="float:left;margin-right:5px;"/&gt;
&lt;p&gt;I live in the fastest growing corner of one of the fastest growing counties in the US.
Lately that has seemed to come with more than my share of power interruptions.&lt;/p&gt;
&lt;p&gt;This blog is hosted on a &amp;#8216;server&amp;#8217; in my home office, which also hosts several other things, some for internal use, and
others, like talklikeaduck are public facing.  Besides this blog I have a 
wikimedia based site on the &lt;a href="http://www.mercuryspacecraft.com/wiki/Main_Page"&gt;technical history of
Project Mercury&lt;/a&gt;, a personal interest of mine.&lt;/p&gt;
&lt;p&gt;One of my frustrations of late has been the fact that the blog doesn&amp;#8217;t suffer those power interruptions well.
For deployment, I&amp;#8217;m using a combination of Apache 2.0, with pen for load balancing, and mongrel_cluster.  That last has
been the main source of that minor annoyance.  The version of mongrel_cluster I&amp;#8217;ve been using doesn&amp;#8217;t properly deal with
stale pid files, so that when the system reboots after a power outage, the blog doesn&amp;#8217;t come back without manual
intervention.&lt;/p&gt;
&lt;p&gt;My frustration level finally rose to the point where I started to look for a solution.&lt;/p&gt;&lt;/p&gt;


&lt;h2&gt;Stable vs. Backwater&lt;/h2&gt;
&lt;p&gt;The sharp eyed might notice that I&amp;#8217;m using Apache 2.0 instead of the later versions which support 
mod_proxy_load_balancer.  The reason is that the server is running Ubuntu Dapper which doesn&amp;#8217;t have the latest Apache, and
since I have so much other stuff running, I haven&amp;#8217;t wanted to attack that problem.  Don&amp;#8217;t ask me about my php4 to php5
platform migration plans, either.  Wikimedia moved on to &lt;span class="caps"&gt;PHP5&lt;/span&gt; some time back, and I&amp;#8217;ve stopped moving with it.
&lt;/p&gt;
&lt;p&gt;I&amp;#8217;m running Dapper since that&amp;#8217;s the latest Ubuntu &lt;span class="caps"&gt;LTS&lt;/span&gt; release.&lt;/p&gt;
&lt;p&gt;It&amp;#8217;s the usual dilemma of wanting a stable server vs. being left behind.&lt;/p&gt;
&lt;p&gt;For things like Ruby, where I&amp;#8217;ve got the time and interest to spend, I&amp;#8217;ve gone to installing from source rather than
debian packages.  This allows me to keep up, and gets around things like the issues between the views of the debian 
maintainers and the rubygems folks about how software should be installed.&lt;/p&gt;
&lt;h2&gt;Searching For Religion&lt;/h2&gt;
&lt;p&gt;A few weeks ago, I &lt;a href="http://www.rubyinside.com/god-extensible-process-monitoring-framework-559.html"&gt;started 
hearing&lt;/a&gt; about &lt;a href="http://god.rubyforge.org/"&gt;god, a new ruby server monitoring framework.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;So I installed god, only to find that it wouldn&amp;#8217;t install in Ubuntu Dapper.  I asked about this on the ruby-talk forum,
and the developers seemed to agree with me that it might be nice if, as a server oriented offering, god supported Dapper.&lt;/p&gt;
&lt;p&gt;So I&amp;#8217;ve been waiting for god to come to Dapper, but with after another power outage this morning, I decided to look at
alternatives&lt;/p&gt;
&lt;h2&gt;God is inspiring, but who inspired god?&lt;/h2&gt;
&lt;p&gt;God is actually patterned after another non-ruby offering called &lt;a href="http://www.tildeslash.com/monit/index.php"&gt;monit&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Monit has been around awhile, has been packaged for debian, and even is available in packaged form for dapper.
It&amp;#8217;s also &lt;a href="http://www.ubuntugeek.com/monitoring-ubuntu-services-using-monit.html"&gt;showed up recently&lt;/a&gt; in several
of the rss feeds I monitor.&lt;/p&gt;
&lt;p&gt;I think it&amp;#8217;s fair to say that monit:god :: make:rake.&lt;/p&gt;
&lt;h2&gt;Monit and Mongrel_Cluster&lt;/h2&gt;
&lt;p&gt;So this morning I installed monit, and started to configure it.&lt;/p&gt;
&lt;p&gt;While in the midst of doing this I started wondering how best to configure it to monitor a mongrel cluster.  Monit 
is a daemon which periodically examines things like pid files and sees if the processes which they reference are still
running.  It can be configured to automatically restart services when they die, restart them under certain load conditions,
etc.&lt;/p&gt;
&lt;p&gt;The problem is that mongrel_cluster is really responsible for multiple processes, and I was scratching my head over
how to map this to monit for a few seconds before resorting to google.  I noticed that, as I predicted, 
&lt;a href="http://xullicious.blogspot.com/2007/05/chat-update.html"&gt;others&lt;/a&gt; had been 
&lt;a href="http://blog.smartmonkey.org/tags/monit"&gt;there&lt;/a&gt; or in 
&lt;a href="http://www.igvita.com/blog/2006/11/07/monit-makes-mongrel-play-nice/"&gt;similar&lt;/a&gt; places
before.&lt;/p&gt;
&lt;h2&gt;Aha! There&amp;#8217;s a new Mongrel_cluster&lt;/h2&gt;
&lt;p&gt;While perusing the words of wisdom from the pioneers, I noticed that those who had setup monit to monitor clusters of
mongrels were mentioning the need for &lt;a href="http://rubyforge.org/pipermail/mongrel-users/2007-February/003000.html"&gt;
version 1.0.1&lt;/a&gt;
So, as directed I did a 
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;sudo gem install mongrel_cluster --source http://mongrel.rubyforge.org/releases/&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;But when I tried it out, with&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;mongrel_rails cluster::status&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt; mongrel_rails couldn&amp;#8217;t find the
cluster::status command.&lt;/p&gt;
&lt;p&gt;At this point I couldn&amp;#8217;t restart my blog, so I uninstalled the 1.0.1 version of mongrel_cluster, tried to start it again
and, relieved when it did start, looked for a solution.
&lt;p&gt;My first thought was to see if maybe there was an even later version of mongrel_cluster.  Doing a gem list&amp;#8212;remote,
showed that there as a 1.0.2 in the normal source.  So I installed that, and, same problem.&lt;/p&gt;
&lt;p&gt;Then, with a little help from google, I uninstalled the earlier version of mongrel_cluster, and lo and behold, the new
cluster commands worked.&lt;/p&gt;
&lt;h2&gt;Permissions problem&lt;/h2&gt;
&lt;p&gt;But then I ran into another problem. Starting the blog was thowing an exception because of a permissions problem.  
I use an init script to start mongrel_rails, and mongrel_rails runs as a particular user.  The mongrel_cluster init file looks
for existing pid files, and it uses a sequence which changes to the working directory specified in the mongrel cluster
configuration, looks for the file, then changes back to the old working directory.  But the user running it didn&amp;#8217;t have
permission to my home directory which was I started, so it failed when on that change back.&lt;/p&gt;
&lt;p&gt;The solution was to change &lt;strong&gt;my&lt;/strong&gt;init script to change to the rails root of my typo installation &lt;strong&gt;before&lt;/strong&gt; invoking mongrel_rails.  Problem solved.&lt;/p&gt;
&lt;h2&gt;Still waiting for god(ot)&lt;/h2&gt;
&lt;p&gt;So what of monit?&lt;/p&gt;
&lt;p&gt;Now that I&amp;#8217;ve got the new version of mongrel_rails, which properly handles stale pid-files, I&amp;#8217;m less motivated to setup
monit.  I do like the monitoring functions it provides, so I might still pursue it, but on a less urgent priority.&lt;/p&gt;
&lt;p&gt;On the other hand I just might wait for god to bless Dapper, or for the next 
&lt;a href="http://www.linuxtoday.com/news_story.php3?ltsn=2007-07-22-008-26-NW-DB-SW"&gt;Ubuntu &lt;span class="caps"&gt;LTS&lt;/span&gt; release&lt;/a&gt;, whichever comes first.
&lt;/p&gt;</description>
      <pubDate>Thu, 02 Aug 2007 12:23:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:63682887-c407-4884-86a1-35609e3c55f4</guid>
      <author>Rick DeNatale</author>
      <link>http://talklikeaduck.denhaven2.com/articles/2007/08/02/keeping-it-up-your-rails-app-that-is</link>
      <category>rails</category>
      <category>deployment</category>
      <category>ubuntu</category>
      <category>monit</category>
      <category>server</category>
      <category>mongrel</category>
      <category>mongrel_cluster</category>
      <trackback:ping>http://talklikeaduck.denhaven2.com/articles/trackback/450</trackback:ping>
    </item>
  </channel>
</rss>
