unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Eric Wong <normalperson@yhbt.net>
To: unicorn list <mongrel-unicorn@rubyforge.org>
Subject: Re: unicorn simple cgi without rails
Date: Thu, 10 Oct 2013 22:53:56 +0000	[thread overview]
Message-ID: <20131010225356.GA11485@dcvr.yhbt.net> (raw)
In-Reply-To: <BAY168-W75210ADA572964921374F9D41E0@phx.gbl>

nomad Bellcam <damonswirled@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	other threads:[~2013-10-10 22:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-10 22:18 unicorn simple cgi without rails nomad Bellcam
2013-10-10 22:53 ` Eric Wong [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://yhbt.net/unicorn/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131010225356.GA11485@dcvr.yhbt.net \
    --to=normalperson@yhbt.net \
    --cc=mongrel-unicorn@rubyforge.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhbt.net/unicorn.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).