views:

119

answers:

3

On Ubuntu I compiled sbcl 1.0.35 with threading. I can happily use sbcl from the command line and my hunchentoot website works with threading but when I logout it's gone. When I attempt to nohup sbcl

nohup ./src/runtime/sbcl --core output/sbcl.core

I get

(SB-IMPL::SIMPLE-STREAM-PERROR "couldn't read from ~S" # 9)

I've attempted various combinations of redirecting the standard input to /dev/null or a file and using the script command line option but I don't quite get what is going on.

How do I start sbcl from the command line on linux with nohup and keep my repl(website) running?

+1  A: 

RESTAS web-framework ("REST Application Server") by Andrey Moskvitin contains code to properly daemonize SBCL instance. See http://github.com/archimag/restas/blob/master/contrib/restas-daemon.lisp. You can easily rip off RESTAS-specific parts.

dmitry_vk
+1  A: 

You could start SBCL in Gnu Screen and then detach from the session.

This also gives you the possibility to reattach to your REPL later.

rootzlevel
A: 

Dmity-vk sent me on the right track, thank you. SBCL tries to start a repl when you start it up, and reads from the standard in. When you use nohup the standard in is redirected and cannot be read. SBCL then drops to the debugger which tries to read from standard in ... hence the endless loop. The --script tag comes close to solving this except that it has a (quit) once the script has been read. So I put an endless loop in my script and voila.

so on an ubuntu server with sbcl this should let you start a hunchentoot server

sudo nohup ./run-sbcl.sh --script foo.lisp > /dev/null 2> /dev/null &

where foo.lisp has as its last lines something like

(defvar alive t)

(loop (sleep 1000) (if (not alive) (quit)))

Jim