[slime-devel] Swank restart-server Patch
fatman at maxint.net
Sat Dec 1 09:25:36 UTC 2007
I run a long-lived lisp image that I access remotely, and I'd like to
be able to update slime dynamically without stopping and restarting
the whole image. The catch is that after the re-load, I need to
restart the Swank listener thread in case the code for its function
has changed. Although the current CVS version of Slime can stop a
running Swank server by using kill-nth-thread, it doesn't expose the
socket that the thread was listening to. Subsequent threads can't bind
to the port number because there is already a socket using it, and
without a reference to the socket object, it can't be closed.
The attached patch provides this access by defining a new package
variable, *listener-sockets*. There are also two new functions:
stop-server and restart-server. I'm using SBCL 2.6.18, and I have only
tested this code with :spawn style servers, but even though I don't
use :fd-handler or :sigio, I have provided code for them if anyone is
interested in trying it out.
With these changes, an online update to a remote lisp should be
possible from the Slime REPL as follows:
<cvs update slime>
(asdf:oos 'asdf:load-op 'swank)
(swank:restart-server :port 4005 :style :spawn :dont-close t)
<slime-disconnect and restart emacs>
This code works well for me, but I'm not very familiar with Slime
implementation details, so it would not surprise me if I've missed
something important in my patch. I hope it proves useful to others.
Linux: The ultimate video game.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 3439 bytes
Desc: not available
More information about the slime-devel