Eduardo Mu�oz <emufer@terra.es> wrote:
+---------------
| Chris Beggy <chrisb@kippona.com> writes:
| > I've done a simple website with a database using apache + mod_lisp
| > + cmucl + clsql + lml + cl-ppcre. ...
| > Oh, right. uffi + mysql too:
| > http://lisp.t2100cdt.kippona.net/lispy/home
|
| You can see something similar here (my first webserver :)
| http://213.97.131.125/lisp
| Most of the content is static html, generated using Tim
| Bradshaw's htout. The lisp section is dinamic (htout
| again). Keep in mind that the site is still under
| construction. I'm using Debian+Apache+mod_lisp+CMUCL+htout
| for the website and Emacs+ilisp+tramp+detachtty for interactive sessions...
+---------------
I can't show off the database stuff yet (since the data is proprietary),
but I've been having lots of fun hacking some web-based database apps
with FreeBSD + Apache + CMUCL + a tiny CGI library I wrote + Tim's
HTOUT + Eric Marsden's PG + PostgreSQL. Virtually no problems at all
with integration (except my own learning curve with CL). Development
has been quite pleasant!
Because the anticipated traffic is quite low (and because I won't have
complete freedom with the Apache server on the machine that'll be used
in production), I haven't bothered with mod_lisp yet (sorry, Marc!).
Instead, I simply built a saved image of CMUCL with all the above stuff
in it, plus a customized init function which includes a readmacro for #!
which lets plain ol' CGI scripts start with:
#!/usr/local/bin/cmucl -core /usr/local/lib/cmucl/lib/cgi.core
;;;; Lisp code here...
This fortunately works on FreeBSD, despite the two "words" after the
initial #! path. [CMUCL is documented to accept "-core=/path/to/core",
which would allow this to work on other OSes, but it doesn't. When I
get time to learn how to build CMUCL's "lisp" from sources (my first
attempt died with some kind of version skew), I'll fix that. It's a
really simple patch to "lisp/lisp.c:main()".]
As a side benefit, that same "cgi.core" is usable for running all
kinds of non-CGI scripts as well, and FreeBSD's VM system does a
very good job of cacheing the 20+ MB core file (which is mostly
read-only, after all), so that after it's been used one time,
subsequent scripts run *very* fast. E.g., the following script
runs in under 20ms on a 1.4 GHz Athlon, and under 250ms on an
ancient 133 MHz Pentium (with only 48 MB RAM):
% cat foo
#!/usr/local/bin/cmucl -core /usr/local/lib/cmucl/lib/cgi.core
(format t "Hello, world! Args = ~s~%" *script-args*)
% time foo bar baz
Hello, world! Args = ("bar" "baz")
0.011u 0.005s 0:00.01 100.0% 264+5144k 0+0io 0pf+0w
%
So much for complaining about "startup time" for CL. I've just
about given up using anything else for general-purpose scripting!
-Rob
p.s. As long as I'm sharing grotesque hacks, the following is offered
without further explanation or apology: ;-} ;-}
#!/usr/local/bin/cmucl -core /usr/local/lib/cmucl/lib/cgi.core
;;;; Hack to allow CMUCL FASL files to run as shell scripts.
;;;; Usage: cat {this_file} foo1.x86f ... fooN.x86f > foo ; chmod +x foo
;;;; The last "fooN.x86f" should end with a top-level form which runs the app.
(let ((stream (open *script-name* :element-type '(unsigned-byte 8))))
(dotimes (i 8) (read-line stream)) ; Eat header text from stream, then
(load stream :contents :binary) ; pass rest to FASLOAD.
(unix:unix-exit 0)) ; Keep LOAD of script from falling into FASL file(s).
-----
Rob Warnock, PP-ASEL-IA <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607