Subject: Re: mod_lisp over CGI
From: (Rob Warnock)
Date: Thu, 08 Nov 2007 05:31:14 -0600
Newsgroups: comp.lang.lisp
Message-ID: <>
Maciej Katafiasz  <> wrote:
| I'm looking for an option to trampoline into a long-running Lisp process
| with a small CGI handler. Ideally, the trampoline would simply speak the
| mod_lisp protocol, which would allow servers that already know mod_lisp
| (ie. almost all of them) to be run unmodified. The usage scenario is
| having Lisp serve content on hosts where I have neither privileges to
| install Apache modules nor FastCGI available, which describes very many of
| the cheaper shared hosting options.
| One fairly obvious solution would be to have a CGI handler version of
| mod_lisp.c, but I haven't found anything like that, and looking at the
| code, it scares me with Apache API which I have no clue about. So, is
| anyone aware of existence / capable of producing a standalone mod_lisp?
| Also, google and #lisp tell me Rob Warnock has previously mentioned using
| a "tiny C trampoline that speaks a mod_lisp-like protocol", how much
| mod_lisp-like is it (and if sufficiently so, would you be willing to
| share)?

Well, *now* you've gone & done it!! ;-}  You've *finally* forced me
to rummage around in my "nonexistent spare time" junkbox and find one
of them "round tuit" thingamabobs and add an MIT-style copyright notice
to my "cgi_sock.c" program, which is now available to all & sundry here:

As it says there, provided as-is, no warranty, no support. [And no
free consulting, either, so please *DON'T* send me email about it.
It'll just make me grumpy, and won't get you any help.] Though if
you have questions/comments/suggestions and you post them *here*,
somebody [maybe even me?] might respond. Criticisms of the "Why did
you do it *that* way?!?" kind will probably all be answered with this
bolierplate: "When I wrote this I was in a hurry, and it worked
well enough, so I haven't messed with it since." [It's still in use,
unchanged, on several lightly-loaded production web servers out there.]

Since you're not using my idiosyncratic CMUCL-based application server
[which is the *next* thing I need to clean up enough to release!],
you will almost certainly want to change the hardcoded location of
the application server's listening socket, which you do by defining
SOCK_PATH on the compile command line, e.g.:

    cc -O -DSOCK_PATH=/var/run/my_app.sock cgi_sock.c -o cgi_sock

Install with:

    cp -p cgi_sock /path/to/your/cgi-bin/


    cp -p cgi_sock /usr/local/www/htdocs/...some_path.../sock.cgi

Consult the source for the Apache "AddHandler" directives needed
for those two cases.

If you want to maintain protocol compatibility with with "mod_lisp",
you probably don't want to change any of the other "#define"s in the
source [but if not, observe the effect of changing SOCK_PROTOCOL to

And as a bonus... [sorry, no knives, no orange peelers, just more
software]... there's also a tiny/sample/debugging stub app server
that serves up a plaintext HTTP response showing you what all the
"mod_lisp" a.k.a. CGI variables were:

Caveat: I haven't used this since the first week I wrote "cgi_sock.c",
so the socket paths it uses will *NOT* match the current "cgi_sock.c"
paths at all. [You have been warned.]



Rob Warnock			<>
627 26th Avenue			<URL:>
San Mateo, CA 94403		(650)572-2607