<?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>Off you go... into the purple yonder! &#187; rubyforge</title>
	<atom:link href="https://ward.vandewege.net/blog/tag/rubyforge/feed/" rel="self" type="application/rss+xml" />
	<link>https://ward.vandewege.net/blog</link>
	<description></description>
	<lastBuildDate>Sun, 12 May 2024 20:57:05 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>monit, mongrel_rails and ENV[&quot;HOME&quot;]</title>
		<link>https://ward.vandewege.net/blog/2009/06/monit-mongrel_rails-and-envhome/</link>
		<comments>https://ward.vandewege.net/blog/2009/06/monit-mongrel_rails-and-envhome/#comments</comments>
		<pubDate>Sun, 28 Jun 2009 14:46:20 +0000</pubDate>
		<dc:creator><![CDATA[ward]]></dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[ENV["HOME"]]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[mongrel]]></category>
		<category><![CDATA[mongrel_rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[rubyforge]]></category>

		<guid isPermaLink="false">http://ward.vandewege.net/blog/?p=469</guid>
		<description><![CDATA[So your mongrels are humming along happily and you have monit monitoring them with a definition like this: check process mongrel_8010 with pidfile /path/to/current/log/mongrel.8010.pid start program = "/usr/bin/mongrel_rails cluster::start -C /path/to/current/config/mongrel_cluster.yml --clean --only 8010" stop program = "/usr/bin/mongrel_rails cluster::stop -C &#8230; <a href="https://ward.vandewege.net/blog/2009/06/monit-mongrel_rails-and-envhome/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>So your mongrels are humming along happily and you have monit monitoring them with a definition like this:</p>
<pre>
check process mongrel_8010 with pidfile /path/to/current/log/mongrel.8010.pid
  start program = "/usr/bin/mongrel_rails cluster::start -C /path/to/current/config/mongrel_cluster.yml --clean --only 8010"
  stop program = "/usr/bin/mongrel_rails cluster::stop -C /path/to/current/config/mongrel_cluster.yml --clean --only 8010"

  if failed host 127.0.0.1 port 8010
    with timeout 10 seconds
    then restart

  if totalmem > 128 Mb then restart
  if cpu is greater than 60% for 2 cycles then alert
  if 3 restarts within 5 cycles then timeout
  group mongrel
</pre>
<p>The start/stop commands work perfectly from the command line, but somehow not when monit&#8217;s calling them. Sure enough, you find this in the mongrel.8010.log file:</p>
<pre>
/usr/lib/ruby/gems/1.8/gems/rubyforge-1.0.3/lib/rubyforge.rb:15:in `expand_path': couldn't find HOME environment -- expanding `~' (ArgumentError)
</pre>
<p>The line in question is</p>
<pre>
  HOME        = ENV["HOME"] || ENV["HOMEPATH"] || File::expand_path("~")
</pre>
<p>Monit does not set a HOME environment variable, nor HOMEPATH.</p>
<p>The documentation for File::expand_path says:</p>
<pre>
Converts a pathname to an absolute pathname. Relative paths are referenced from the 
current working directory of the process unless dir_string is given, in which case it 
will be used as the starting point. The given pathname may start with a ``~â€™â€™, which 
expands to the process ownerâ€˜s home directory (the environment variable HOME must 
be set correctly). ``~userâ€™â€™ expands to the named userâ€˜s home directory. 
</pre>
<p>Ouch. So if HOME is not set, File::expand_path(&#8220;~&#8221;) is guaranteed to fail. That&#8217;s a bug in the rubyforge gem I think.</p>
<p>I worked around this by setting ENV["HOME"] to a fallback value before the</p>
<pre>
require 'rubygems'
</pre>
<p>line in /usr/bin/mongrel_rails.</p>
<p>I <a href="http://rubyforge.org/tracker/index.php?func=detail&#038;aid=26447&#038;group_id=1024&#038;atid=4025">filed a bug</a>. It took me a while to figure out that the rubyforge gem is part of the <a href="http://rubyforge.org/projects/codeforpeople/">codeforpeople</a> project on <a href="http://rubyforge.org">rubyforge</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://ward.vandewege.net/blog/2009/06/monit-mongrel_rails-and-envhome/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
