2011/5/2 Heka Treep <zena.treep@...>:
> 2) Use pure-lisp solution, i.e. do demonization in lisp in late stage,
> when VM is already running. The problem is that we can't do
> daemonization simply (standard sequence of calls to fork, setsid,
> umask, chdir, open("/dev/null") and dup2 on 0/1/2 descriptors is just
> don't work) and need to do additional steps. Also, restarter can't
> live in VM, because if the VM falls, restarter fall too. It must be an
> external C program, or individual sbcl process (which is not optimal
> for memory usage).
I have a few servers deployed using a pure-lisp demonization setup. It
works just fine, and has the added benefit of only demonizing once the
program has successfully opened its log files, bound the port, etc.,
so it can report startup errors to the user who started it (as well as
the log file, if it can open it). The additional memory usage per
active process is quite reasonable (something like 20 MB per child
process). The rest of the overhead gets shared between all the running
SBCLs. This is the solution I would recommend to anyone writing a
server with SBCL -- it works just fine[*] for us, and the result
behaves like a normal unix daemon.
[*] Fine, except for an external-format issue: we had to hack the C
external format code to force SBCL to use UTF8 as the default external
format, even on machines which don't have a utf8 locale.