As we rapidly approach our semi-public Beta stage, I’ve switched from using WEBrick to Lighttpd (or ‘lightie’ as they like to call it *shudder*) as the web server. This also means switching to FastCGI. A brief overview on Oxyliquit gives the configuration that you’ll need which usually lives in /etc/lighttpd.conf on Linux or /usr/local/etc/lighttpd.conf on … Continue reading “Moving from WEBrick to lighttpd/FastCGI in Nitro”
As we rapidly approach our semi-public Beta stage, I’ve switched from using WEBrick to Lighttpd (or ‘lightie’ as they like to call it *shudder*) as the web server. This also means switching to FastCGI. A brief overview on Oxyliquit gives the configuration that you’ll need which usually lives in /etc/lighttpd.conf on Linux or /usr/local/etc/lighttpd.conf on FreeBSD.
Here are some issues I’ve run into, in the hope that they’ll be useful to someone else.
When starting lighttpd, if I have more than one fcgi process (min-procs
and/or max-procs
> 1), Nitro starts the Og.setup once for each process. This means that you have to turn off schema evolution (:evolve_schema => false
) and obviously make Og not drop the database at start-up (:destroy => false
).
Nitro doesn’t know what your template directory is by default under fcgi. In your run.rb (or whatever script you use to start your Nitro app) insert Template.root = '/path/to/your/template/dir'
before you start your app.
Nitro (and Og) doesn’t log everything properly into your log/app.log. This is some weirdness in the code base, which hopefully will get tracked down (possibly by me), but as a work around (thanks Brian!) put the following two lines at the top of your run.rb:
require 'glue/logger'
Logger.set Logger.new('/path/to/your/app.log')
Finally, if like me you’re using Nitro/Og in a REST-style manner, you may want to get access to the body of any post request. In WEBrick I did this with request.raw_body
, but this doesn’t work with FastCGI. Unfortunately, there is no workaround for this that I can find, so I’ll be writing a fix tonight, and posting to the Nitro mailing list (and here in the comments).
Technorati Tags: lighttpd, nitro, fastcgi, ruby