<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: HOWTO: Custom Mongrel Handlers</title>
	<link>http://adam.blogs.bitscribe.net/2007/05/06/howto-custom-mongrel-handlers/</link>
	<description>software sophistry</description>
	<pubDate>Thu, 28 Aug 2008 02:14:04 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.2</generator>
		<item>
		<title>By: reality &#187; Blog Archive &#187; Ruby on Rails + AJAX + Mongrel + JMS/MQ/MOM = å³æ™‚é€šè¨Š</title>
		<link>http://adam.blogs.bitscribe.net/2007/05/06/howto-custom-mongrel-handlers/#comment-12472</link>
		<dc:creator>reality &#187; Blog Archive &#187; Ruby on Rails + AJAX + Mongrel + JMS/MQ/MOM = å³æ™‚é€šè¨Š</dc:creator>
		<pubDate>Sun, 01 Jul 2007 18:00:52 +0000</pubDate>
		<guid>http://adam.blogs.bitscribe.net/2007/05/06/howto-custom-mongrel-handlers/#comment-12472</guid>
		<description>[...] HOWTO: Custom Mongrel Handler - Building mongrel http handler [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] HOWTO: Custom Mongrel Handler - Building mongrel http handler [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: adam</title>
		<link>http://adam.blogs.bitscribe.net/2007/05/06/howto-custom-mongrel-handlers/#comment-6437</link>
		<dc:creator>adam</dc:creator>
		<pubDate>Fri, 11 May 2007 11:07:26 +0000</pubDate>
		<guid>http://adam.blogs.bitscribe.net/2007/05/06/howto-custom-mongrel-handlers/#comment-6437</guid>
		<description>Pratik -

As Rick pointed out, you actually do have most of the Rails environment.  Mongrel is running in the same VM process as Rails.  What you don't get is ActionController, which includes stuff like automatic parsing of your CGI parameters, sessions, and template rendering.  (It should be possible to render ERB with lower-level calls, although ERB is pretty slow too, so if you're doing this for optimization's sake that might be counterproductive.)</description>
		<content:encoded><![CDATA[<p>Pratik -</p>
<p>As Rick pointed out, you actually do have most of the Rails environment.  Mongrel is running in the same VM process as Rails.  What you don&#8217;t get is ActionController, which includes stuff like automatic parsing of your CGI parameters, sessions, and template rendering.  (It should be possible to render ERB with lower-level calls, although ERB is pretty slow too, so if you&#8217;re doing this for optimization&#8217;s sake that might be counterproductive.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pratik</title>
		<link>http://adam.blogs.bitscribe.net/2007/05/06/howto-custom-mongrel-handlers/#comment-6436</link>
		<dc:creator>Pratik</dc:creator>
		<pubDate>Fri, 11 May 2007 10:28:52 +0000</pubDate>
		<guid>http://adam.blogs.bitscribe.net/2007/05/06/howto-custom-mongrel-handlers/#comment-6436</guid>
		<description>I'm wondering if it's possible to subclass the handler from Mongrel::Rails::RailsHandler instead of Mongrel::HttpHandler and get the entire rails environment inside the handler ?</description>
		<content:encoded><![CDATA[<p>I&#8217;m wondering if it&#8217;s possible to subclass the handler from Mongrel::Rails::RailsHandler instead of Mongrel::HttpHandler and get the entire rails environment inside the handler ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: links for 2007-05-11 &#171; Bloggitation</title>
		<link>http://adam.blogs.bitscribe.net/2007/05/06/howto-custom-mongrel-handlers/#comment-6375</link>
		<dc:creator>links for 2007-05-11 &#171; Bloggitation</dc:creator>
		<pubDate>Fri, 11 May 2007 00:21:18 +0000</pubDate>
		<guid>http://adam.blogs.bitscribe.net/2007/05/06/howto-custom-mongrel-handlers/#comment-6375</guid>
		<description>[...] Custom Mongrel Handlers (tags: ruby mongrel web programming) [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] Custom Mongrel Handlers (tags: ruby mongrel web programming) [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: adam</title>
		<link>http://adam.blogs.bitscribe.net/2007/05/06/howto-custom-mongrel-handlers/#comment-5970</link>
		<dc:creator>adam</dc:creator>
		<pubDate>Tue, 08 May 2007 23:17:57 +0000</pubDate>
		<guid>http://adam.blogs.bitscribe.net/2007/05/06/howto-custom-mongrel-handlers/#comment-5970</guid>
		<description>Rick -

Excellent, I wasn't even thinking about the fact that the mongrel process is actually executing in the same Ruby VM.

What's the point of the mutex, though?  The database certainly can handle simultaneous queries; is ActiveRecord not threadsafe?  I though that ActionController was the only offender in that dept.

In any case, I'll update the post with your improved version.</description>
		<content:encoded><![CDATA[<p>Rick -</p>
<p>Excellent, I wasn&#8217;t even thinking about the fact that the mongrel process is actually executing in the same Ruby VM.</p>
<p>What&#8217;s the point of the mutex, though?  The database certainly can handle simultaneous queries; is ActiveRecord not threadsafe?  I though that ActionController was the only offender in that dept.</p>
<p>In any case, I&#8217;ll update the post with your improved version.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rick</title>
		<link>http://adam.blogs.bitscribe.net/2007/05/06/howto-custom-mongrel-handlers/#comment-5960</link>
		<dc:creator>rick</dc:creator>
		<pubDate>Tue, 08 May 2007 21:49:05 +0000</pubDate>
		<guid>http://adam.blogs.bitscribe.net/2007/05/06/howto-custom-mongrel-handlers/#comment-5960</guid>
		<description>One thing to keep in mind: since your handler is being run alongside a rails app, you shouldn't have to establish the connection of the ActiveRecord object.  It should be the exact same class that's being used in the rails app.  You also might want to put a mutex around your DB calls.

http://pastie.caboo.se/59978</description>
		<content:encoded><![CDATA[<p>One thing to keep in mind: since your handler is being run alongside a rails app, you shouldn&#8217;t have to establish the connection of the ActiveRecord object.  It should be the exact same class that&#8217;s being used in the rails app.  You also might want to put a mutex around your DB calls.</p>
<p><a href="http://pastie.caboo.se/59978" rel="nofollow">http://pastie.caboo.se/59978</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rick</title>
		<link>http://adam.blogs.bitscribe.net/2007/05/06/howto-custom-mongrel-handlers/#comment-5957</link>
		<dc:creator>rick</dc:creator>
		<pubDate>Tue, 08 May 2007 21:41:30 +0000</pubDate>
		<guid>http://adam.blogs.bitscribe.net/2007/05/06/howto-custom-mongrel-handlers/#comment-5957</guid>
		<description>The mongrel site includes my tutorial on using "upload progress gem":http://mongrel.rubyforge.org/docs/upload_progress.html, which is implemented as a simple mongrel handler.  This is a good tutorial though.  I'm working on a similar article for a minimal mongrel handler.

Greg: the : in front of the yaml keys is so the values can be accessed with a symbol.  yaml[:config_script] vs yaml['config_script'].</description>
		<content:encoded><![CDATA[<p>The mongrel site includes my tutorial on using &#8220;upload progress gem&#8221;:http://mongrel.rubyforge.org/docs/upload_progress.html, which is implemented as a simple mongrel handler.  This is a good tutorial though.  I&#8217;m working on a similar article for a minimal mongrel handler.</p>
<p>Greg: the : in front of the yaml keys is so the values can be accessed with a symbol.  yaml[:config_script] vs yaml[&#8217;config_script&#8217;].</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam @ Bitscribe &#187; Comet with Rails + Mongrel</title>
		<link>http://adam.blogs.bitscribe.net/2007/05/06/howto-custom-mongrel-handlers/#comment-5872</link>
		<dc:creator>Adam @ Bitscribe &#187; Comet with Rails + Mongrel</dc:creator>
		<pubDate>Tue, 08 May 2007 10:10:44 +0000</pubDate>
		<guid>http://adam.blogs.bitscribe.net/2007/05/06/howto-custom-mongrel-handlers/#comment-5872</guid>
		<description>[...] In my last post I described how to create a mongrel handler. I said you might want to do this for optimization purposes, but my own interest came about in an attempt to solve the server-push problem with Rails. [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] In my last post I described how to create a mongrel handler. I said you might want to do this for optimization purposes, but my own interest came about in an attempt to solve the server-push problem with Rails. [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Greg</title>
		<link>http://adam.blogs.bitscribe.net/2007/05/06/howto-custom-mongrel-handlers/#comment-5767</link>
		<dc:creator>Greg</dc:creator>
		<pubDate>Mon, 07 May 2007 17:08:13 +0000</pubDate>
		<guid>http://adam.blogs.bitscribe.net/2007/05/06/howto-custom-mongrel-handlers/#comment-5767</guid>
		<description>Hey Adam, nice post. This stuff is complicated enough that it helps to have lots of people's takes on it. Anyway, I can answer your question about loading a custom handler from a config script. I ran into the same problem. The keyword is, in fact, config_script, but in your yaml, you've got to precede it with a colon like this:

---
:config_script: lib/mongrel_handlers/jsonp_handler.rb

I don't know why it wants the colons, but that's what the examples look like on the Mongrel site and that's what works (treating them as hash keys?). Once you've got that setup, you can just load the conf file as normal:

mongrel_rails start -C config/mongrel_conf.yml

And mongrel will find the handler (you can see it in the printout if you launch mongrel without the -d flag).</description>
		<content:encoded><![CDATA[<p>Hey Adam, nice post. This stuff is complicated enough that it helps to have lots of people&#8217;s takes on it. Anyway, I can answer your question about loading a custom handler from a config script. I ran into the same problem. The keyword is, in fact, config_script, but in your yaml, you&#8217;ve got to precede it with a colon like this:</p>
<p>&#8212;<br />
:config_script: lib/mongrel_handlers/jsonp_handler.rb</p>
<p>I don&#8217;t know why it wants the colons, but that&#8217;s what the examples look like on the Mongrel site and that&#8217;s what works (treating them as hash keys?). Once you&#8217;ve got that setup, you can just load the conf file as normal:</p>
<p>mongrel_rails start -C config/mongrel_conf.yml</p>
<p>And mongrel will find the handler (you can see it in the printout if you launch mongrel without the -d flag).</p>
]]></content:encoded>
	</item>
</channel>
</rss>
