nomad Bellcam <damonswir...@hotmail.com> wrote:
> my website is mostly static with some small cgi areas, and i like to
> use ruby for the cgi. when i did my research for the best ruby cgi
> handler for nginx, unicorn figured prominently in my results, and so i
> became interested in trying it. i spent some time reading up on how to
> configure and use it but have been unsuccessful implementing, mostly i
> believe due to the fact that i do not have a rails framework installed
> nor a legitimate rackup config.ru

> my question is this: does it make any sense at all to use unicorn as a
> ruby cgi handler if i am not also using rails?

Yes, but perhaps Rainbows! (a sister project of unicorn) is better
<http://rainbows.rubyforge.org/> since it has less overhead when
waiting for a big CGI to run.  If performance/scalability isn't
an issue, then unicorn is fine for CGI.  unicorn is much easier
to configure as there's less documentation to read :)

> and if there is indeed
> some sense in this idea, how might i go about it? is there a simple
> rackup file that would work for a configuration such as this? i
> couldn't find any information on rackup configs of this sort, and not
> being familiar with rails the terrain simply became to steep at this
> point to continue without some guidance or assurances.

You can check out rack-legacy git://github.com/eric1234/rack-legacy

I've never used rack-legacy, as I've been running the bundled
Unicorn::App::ExecCGI before with cgit <http://git.zx2c4.com/cgit/>.
I haven't used it on anything but cgit, however.

I use the following for serving http://bogomips.org/unicorn.git

(I run this with Rainbows!, but it's fine with unicorn, too)
------------------------ config.ru ------------------------
require "unicorn/app/exec_cgi"
map("http://bogomips.org/";) do
  repo = "/path/to/my/git/repos/on/bogomips.org"
  cgit = Unicorn::App::ExecCgi.new("#{repo}/cgit.cgi")

  # Attempts static file serving with Rack::File, first.
  # Fall back to calling cgit if the URL matches .git
  # Otherwise, just return a 404
  r404 = [ 404, [ %w(Content-Length 0), %w(Content-Type text/plain) ], [] ]
  cgit_wrap = lambda { |e| e["PATH_INFO"] =~ %r{\.git} ? cgit.call(e) : r404 }
  run Rack::Cascade.new([ Rack::File.new(repo), cgit_wrap ])
end
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

Reply via email to