How to attach to a Running Common Lisp Application
Almost all the CL books mention about the feature of LISP Applications wherein one can “attach” to a running process and change code dynamically, almost magically. Unfortunately, there isn’t any pragmatic documentation on the subject. Ofcourse there are tools like SLIME, but they are tied to emacs or a particular client. Inspired by Daniel Barlow’s detachtty, I wrote an utility called boots
Boots is a tool that helps install, build and launch CL applications. It also provides a facility to attach and detach from these running applications. It is a convenient wrapper on top of clbuild. Currently, it works only with SBCL. Here is a brief usage of boots:
Boots is a self-extracting script and very easy to install.
$ wget http://github.com/icylisper/boots/blob/master/boots $ ./boots self-install
To list the available application definitions:
$ boots list Available app definitions: - beirc - cells - climacs - closure - common-music - default-swank - gtfl - listener - shuffletron - stumpwm - typeset - weblocks</code>
The simplest image definition is the default one.
$ boots build default-swank $ boots start default-swank
We can connect to the default-swank image from emacs that has SLIME configured.
M-x slime-connect <ip> 4005
Say, we want to try out Andy Hefner’s mcclim-based listener. Just do
$ boots install listener $ boots build listener $ boots start listener
And you should see the wonderful listener launch!
One can attach to the listener tty to debug if something goes wrong
$ boots attach listener C-\ to detach
Now, let us see how to define an application image.
Defining an application image
An application image definition is a directory containing atleast these 3 files named below:
install - script to install the application build - script to compile and generate CL cores/images start - script to launch the application
Now isn’t that easy?