summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/tissue40
1 files changed, 23 insertions, 17 deletions
diff --git a/bin/tissue b/bin/tissue
index fb1656e..bf69100 100755
--- a/bin/tissue
+++ b/bin/tissue
@@ -190,22 +190,30 @@ Export the repository as a website to OUTPUT-DIRECTORY.
(tissue-configuration-web-css (load-config))
(tissue-configuration-web-files (load-config)))))))
-(define (address->socket-address address port)
- "Convert ADDRESS and PORT to a socket address."
+(define (listen->socket-address listen)
+ "Convert LISTEN specification to a socket address."
(cond
+ ;; Unix socket
+ ((string-prefix? "unix:" listen)
+ (make-socket-address AF_UNIX
+ (string-remove-prefix "unix:" listen)))
;; IPv4
- ((string-contains address ".")
- (make-socket-address AF_INET
- (inet-pton AF_INET address)
- port))
+ ((guard (_ (else #f))
+ (inet-pton AF_INET
+ (substring listen 0 (string-index-right listen #\:))))
+ => (lambda (ip)
+ (make-socket-address
+ AF_INET ip (string->number
+ (substring listen (1+ (string-index-right listen #\:)))))))
;; IPv6
- ((string-contains address ":")
- (make-socket-address AF_INET6
- (inet-pton AF_INET6 address)
- port))
- ;; Unix socket
(else
- (make-socket-address AF_UNIX address))))
+ (make-socket-address AF_INET6
+ (inet-pton AF_INET6
+ (string-trim-both
+ (substring listen 0 (string-index-right listen #\:))
+ (char-set #\[ #\])))
+ (string->number
+ (substring listen (1+ (string-index-right listen #\:))))))))
(define tissue-run-web
(match-lambda*
@@ -227,9 +235,8 @@ Run a web search service reading configuration from CONFIG-FILE.
(append (call-with-input-file config-file
read)
result))
- ;; Default address and port
- '((address . "127.0.0.1")
- (port . 8080)))))
+ ;; Default listen
+ '((listen . "127.0.0.1:8080")))))
(let ((listen-repl (assq-ref args 'listen-repl)))
(when listen-repl
(spawn-server (cond
@@ -243,8 +250,7 @@ Run a web search service reading configuration from CONFIG-FILE.
"REPL server listening on ~a~%"
listen-repl)
(make-unix-domain-server-socket #:path listen-repl))))))
- (start-web-server (address->socket-address (assq-ref args 'address)
- (assq-ref args 'port))
+ (start-web-server (listen->socket-address (assq-ref args 'listen))
%xapian-index
(tissue-configuration-web-css (load-config)))))))