Scheme wouldn’t be Scheme without support for live hacking, and your favorite service manager had to support it too! The REPL service provides a read-eval-print loop (REPL) that lets you interact with it from the comfort of the Guile REPL (see Running Guile Interactively in GNU Guile Reference Manual).
The service listens for connections on a Unix-domain socket—by default
/var/run/shepherd/repl when running as root and
/run/user/uid/shepherd/repl otherwise—and spawns a new
service for each client connection. Clients can use the REPL as they
would do with a “normal” REPL, except that it lets them inspect and
modify the state of the shepherd
process itself.
Caveat: The live REPL is a powerful tool in support of live hacking and debugging, but it’s also a dangerous one: depending on the code you execute, you could lock the
shepherd
process, make it crash, or who knows what.One particular aspect to keep in mind is that
shepherd
currently uses Fibers in such a way that scheduling among fibers is cooperative and non-preemptive. Beware!
A configuration file that enables the REPL service looks like this:
(use-modules (shepherd service repl)) (register-services (list (repl-service)))
With that in place, you can later start the REPL:
herd start repl
From there you can connect to the REPL socket. If you use Emacs, you
might fancy doing it with Geiser’s geiser-connect-local
function
(see Geiser User Manual).
The (shepherd service repl)
module exports the following
bindings.
Return a REPL service that listens to socket-file.
This parameter specifies the socket file name repl-service
uses
by default.