* * * * *
I haven't dont a metablog post in a while …
In addition to updating [1] the greylist daemon [2], I've also updated the
software that runs this blog [3].
The biggest change this time is to the configuration file. The first stab at
changing how it works was made back in (let me check … oh wow! was it that
long ago?) September of 2010. Prior, I had code that checked the
SCRIPT_FILENAME environment variable (passed in by Apache [4]) and changed
the extention from .cgi to .cnf to locate the file. That meant the
configuration file had to live in the main web directory and frankly, I felt
that bit of code was always a bit of a hack.
I changed that, however, by configuring Apache to pass the configuration
filename explicitly to the script:
> <VirtualHost 66.252.224.242:80>
> # ...
>
> <Files boston.cgi>
> SetEnv BLOG_CONFIG /home/spc/web/sites/boston.conman.org/journal/boston.cnf
> </Files>
>
> # ...
> </VirtualHost>
>
Now, no more hacking around with filenames, and the configuration file no
longer needs to be stored in a web-facing location. If you do use this
method, you'll need to check REDIRECT_BLOG_CONFIG as well (which Apache sets
when it does a redirect, and only a redirect).
And that was it for the configuration file until earlier this month. The next
big change is how it looks. Prior to the changes this month, the
configuration file looked like:
> Comment:
> Comment: *********************************************
> Comment: *
> Comment: * Configure File for the Boston Diaries
> Comment: *
> Comment: **********************************************
> Comment:
> Name: The Boston Diaries
> Backend: /home/spc/source/boston.old.1.9/sbg/bp
> BaseDir: /home/spc/web/sites/boston.conman.org/journal
> WebDir: /home/spc/web/sites/boston.conman.org/htdocs/
> BaseUrl: /
> FullBaseUrl:
http://boston.conman.org
> Templates: html/regular
> DayPage: /home/spc/web/sites/boston.conman.org/htdocs/index.html
> Days: 7
> RssFile: /home/spc/web/sites/boston.conman.org/htdocs/bostondiaries.rss
> RssTemplates: rss
> RssFirst: latest
> AtomFile: /home/spc/web/sites/boston.conman.org/htdocs/index.atom
> AtomTemplates: atom
> Comment: TabTemplates: html/sidebar
> Comment: TabFile: /home/spc/web/sites/boston.conman.org/htdocs/boston.tab.html
> Comment: TabFirst: latest
> StartDate: 1999/12/4
> Author: Sean Conner
> Comment: Authors: /home/spc/web/sites/boston.conman.org/users
> Email:
[email protected]
> Email-List: /home/spc/web/sites/boston.conman.org/notify/db/email
> Email-Message: /home/spc/web/sites/boston.conman.org/notify/mail/notify
> Email-Subject: The Boston Diaries Update Notification
> Facebook-AP-ID: XXXXXXXXXXXXXXX
> Facebook-AP-Secret: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
> Facebook-User: XXXXXX
> _System-CPU: 600
> _System-Mem: 20971520
> _System-Core: 0
> _System-Locale: en_SPC
>
Let me explain how this came about. I had code to parse RFC-822 [5] style
headers (because at the time I had code to fetch pages via HTTP (HyperText
Transport Protocol) and it's needed there; also, I can accept entries via
email and I need it there too) and instead of writing even more code to parse
a configuration file, I decided to shoehorn the configuration file into an
RFC-822 format.
And thus, the odd format for the configuration file. It's also never been
fully clensed of old features (I no longer have a backend, so the Backend:
header could go; I removed support for the tab template, so TabTemplates:,
TabFile: and TabFirst: could go as well—don't bother asking what the tab file
was for, it'll take too long to explain and as far as I know, nobody,
including myself, ever bother using it).
Even since I started playing around [6] with Lua [7], I've been playing
around with the idea of using it as a configuration file, and I finally got
around to doing it.
> process = require("org.conman.process")
> os = require("os")
>
> -- ---------------------------------------------------------------------
> -- Custom locale to get "Debtember" without special code in the program
> -- ---------------------------------------------------------------------
>
> os.setlocale("en_SPC")
>
> -- --------------------------------------------------------------------
> -- process limits added because an earlier version of the code actually
> -- crashed the server it was running on, due to resource exhaustion.
> -- --------------------------------------------------------------------
>
> process.limits.hard.cpu = "10m" -- 10 minutes
> process.limits.hard.core = 0 -- no core file
> process.limits.hard.data = "20m" -- 20 MB
>
> -- --------------------------------------------------------
> -- We now resume our regularly scheduled config file
> -- --------------------------------------------------------
>
> name = "The Boston Diaries"
> basedir = "/home/spc/web/sites/boston.conman.org/journal"
> webdir = "/home/spc/web/sites/boston.conman.org/htdocs"
> url = "
http://boston.conman.org/"
> author = { name = "Sean Conner" , email = "
[email protected]" }
> startdate = "1999/12/4"
>
> templates =
> {
> {
> template = "html/regular",
> output = webdir .. "/index.html",
> items = "7days",
> reverse = true
> },
>
> {
> template = "rss",
> output = webdir .. "/bostondiaries.rss",
> items = 15,
> reverse = true
> },
>
> {
> template = "atom",
> output = webdir .. "/index.atom",
> items = 15,
> reverse = true
> }
> }
>
> email =
> {
> list = "/home/spc/web/sites/boston.conman.org/notify/db/email",
> message = "/home/spc/web/sites/boston.conman.org/notify/mail/notify",
> subject = name .. " Update Notification",
> }
>
> facebook =
> {
> ap_id = "XXXXXXXXXXXXXXX",
> ap_secret = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
> user = "XXXXXX"
> }
>
> affiliate =
> {
> {
> proto = "asin",
> link = "
http://www.amazon.com/exec/obidos/ASIN/%s/conmanlaborat-20"
> }
> }
>
>
Not only does it look much nicer (Whitespace! Real comments!) but I was able
to remove code to handle the resource limits (it's now handled in Lua—and
I'll talk about that in another entry) and locales (which supports a feature
I added back in October 2003 [8]).
Also, by doing this, I partially cleaned up the template mess. Before, I had
to explicitely add code to support specialized templates (the HTML (HyperText
Markup Language) output, the RSS [9] and ATOM [10] feed files and the long-
since-removed tab file); now, I can specify new templates by just adding them
to the configuration file. The only limitation is that the HTML template has
to be specified first (it's easier to code that way).
You'll also notice a section labeled affiliate. That I threw in at the last
moment. I'm an Amazon [11] affiliate and if I wanted to link to, say, a book
from my friend Hoade, I would have to manually generate the link, but now, I
can just do:
> <a class="book" href="asin:0595095291">Ain't that America</a>
>
and it'll be converted automatically to the correct link:
> <a class="book"
> href="
http://www.amazon.com/exec/obidos/ASIN/http://www.amazon.com/exec/obidos/ASIN/0595095291/conmanlaborat-20">Ain't
> that America</a>
>
Or rather, Hoade's book _Ain't that America_ [12].
On the down side, in trying to release this (the last releast was in
September of 2009, and before that, July of 2004) I found a rather curious
bug—below a certain threshhold of entries (and there're currently over 3,700
here in this blog), the program crashes. There's probably an assumption built
into the code about there always being a previous entry, but for a new blog,
that's not necessarily the case and in tracking down the issue, I found that
it appears to have something to do with the internal caching I do of entries.
Like the old joke goes:
> There are only two hard problems in Computer Science: cache invalidation,
> naming things, and off-by-one errors.
>
And I think I'm being hit by one of—
Core error - bus dumped
[1]
gopher://gopher.conman.org/0Phlog:2011/11/27.1
[2]
http://www.x-grey.com/
[3]
https://boston.conman.org/
[4]
http://httpd.apache.org/
[5]
http://www.ietf.org/rfc/rfc822.txt
[6]
gopher://gopher.conman.org/0Phlog:2009/10/14.3
[7]
http://www.lua.org/
[8]
gopher://gopher.conman.org/0Phlog:2003/10/23.1
[9]
http://en.wikipedia.org/wiki/RSS
[10]
http://en.wikipedia.org/wiki/Atom_(standard)
[11]
http://www.amazon.com/
[12]
https://www.amazon.com/exec/obidos/ASIN/0595095291/conmanlaborat-20
Email author at
[email protected]