[Mongrel] Multiple DocRoots
Todd Fisher
todd.fisher at gmail.com
Wed Dec 27 14:33:39 EST 2006
Ah yes, here's the solution I landed on =>
require 'mongrel/handlers.rb'
class MultipleDirHandler < Mongrel::DirHandler
# check in each folder for the file
def initialize(*path)
@paths = path
super(@paths[0])
end
# check each folder
def can_serve(path_info)
@paths.each do|path|
@path = File.expand_path(path) # to allow RAILS_ROOT
ret = super(path_info)
return ret unless ret.nil?
end
@path = @paths[0]
return nil
end
end
Working really well. Thank you!
-Todd
On 12/27/06, Zed A. Shaw <zedshaw at zedshaw.com> wrote:
>
> On Wed, 27 Dec 2006 13:17:28 -0500
> "Todd Fisher" <todd.fisher at gmail.com> wrote:
>
> > I'm wondering if it's possible to setup mongrel to have multiple
> document
> > roots? The use case I'm trying to solve is one where I have a library
> of
> > shared CSS/JS/Images and would like multiple rails application to use
> them.
> > I have written a proxy controller and added some routes to serve the
> static
> > files and it works reasonably well, but is extremely slow, because it's
> > single threaded. I'd like mongrel to serve these files. I'm wondering
> if
> > there is a way to use -s option to add an aditional document root
> handler.
>
> Piece of cake. Let's say I want a rails public directory to be at both /
> and at /newplace/ then I just do this:
>
> 1) Put this in a mongrel.conf file:
>
> uri "/newplace", :handler => DirHandler.new("public")
>
> 2) Run mongrel like this:
>
> mongrel_rails start -S mongrel.conf
>
> 3) Go to http://localhost:3000/newplace/ and you see the same thing as
> http://localhost:3000/
>
> That's it.
>
> --
> Zed A. Shaw, MUDCRAP-CE Master Black Belt Sifu
> http://www.zedshaw.com/
> http://www.awprofessional.com/title/0321483502 -- The Mongrel Book
> http://mongrel.rubyforge.org/
> http://www.lingr.com/room/3yXhqKbfPy8 -- Come get help.
> _______________________________________________
> Mongrel-users mailing list
> Mongrel-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/mongrel-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20061227/d4881eaf/attachment-0001.html
More information about the Mongrel-users
mailing list