summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac <arunisaac@systemreboot.net>2022-01-03 01:13:25 +0530
committerRicardo Wurmus <rekado@elephly.net>2022-01-07 16:42:23 +0100
commit8573667f538e2e65c9dd59b7f8fc5c02d3da32a5 (patch)
tree88bad0e2b34a7c43c0c6b50ca5779bc84c018d0e
parentac21057c902cc762f35be039b89c88c6db2b1de1 (diff)
scripts: Allow the REPL to listen on Unix domain sockets.
* scripts/mumi.in (%options): Do not error out on non-numeric listen-repl arguments. Spawn REPL server on a TCP socket if listen-repl is numeric, else spawn REPL server on a Unix domain socket.
-rw-r--r--scripts/mumi.in27
1 files changed, 15 insertions, 12 deletions
diff --git a/scripts/mumi.in b/scripts/mumi.in
index 9c997a2..755dfb3 100644
--- a/scripts/mumi.in
+++ b/scripts/mumi.in
@@ -85,12 +85,8 @@
(error "invalid web server port" arg)))))
(option '("listen-repl") #f #t
(lambda (opt name arg result)
- (let ((port (cond (arg => string->number)
- (else %default-repl-server-port))))
- (if port
- (alist-cons 'listen-repl port
- (alist-delete 'listen-repl result))
- (error "invalid REPL server port" arg)))))
+ (alist-cons 'listen-repl (or (string->number arg) arg)
+ (alist-delete 'listen-repl result))))
(option '("disable-mailer") #f #f
(lambda (opt name arg result)
(alist-cons 'disable-mailer #t result)))
@@ -150,12 +146,19 @@
(("web" . rest)
(let ((opts (parse-options rest)))
(parameterize ((mailer-enabled? (not (assoc-ref opts 'disable-mailer))))
- (let ((repl-port (assoc-ref opts 'listen-repl)))
- (when repl-port
- (format (current-error-port)
- "REPL server listening on port ~a~%"
- repl-port)
- (spawn-server (make-tcp-server-socket #:port repl-port))))
+ (let ((listen-repl (assoc-ref opts 'listen-repl)))
+ (when listen-repl
+ (cond
+ ((number? listen-repl)
+ (format (current-error-port)
+ "REPL server listening on port ~a~%"
+ listen-repl)
+ (spawn-server (make-tcp-server-socket #:port listen-repl)))
+ (else
+ (format (current-error-port)
+ "REPL server listening on ~a~%"
+ listen-repl)
+ (spawn-server (make-unix-domain-server-socket #:path listen-repl))))))
(start-mumi-web-server (or (assoc-ref opts 'address)
"0.0.0.0")
(or (assoc-ref opts 'port)