diff options
author | Christopher R. Nelson <christopher.nelson@languidnights.com> | 2024-01-17 21:05:37 -0500 |
---|---|---|
committer | Christopher R. Nelson <christopher.nelson@languidnights.com> | 2024-01-21 09:59:03 -0500 |
commit | a6721bdd6154e2bebd8ab07bf310c25629347a21 (patch) | |
tree | 2b0dad144829f726396b08f09a5eaba3c9b18615 /scripts | |
parent | 2f84ed3f877d97d2327f526ccbe981a6fe3acade (diff) |
Add shutdown command, and refactor server impl
zmq: refactor server to functions
add shutdown function (end recursion)
media: fix bug with missing directories
rh-client: support shutdown function
rh-server: update to use build variables
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/rh-client.in | 28 | ||||
-rwxr-xr-x | scripts/rh-server.in | 16 |
2 files changed, 31 insertions, 13 deletions
diff --git a/scripts/rh-client.in b/scripts/rh-client.in index 64dfde6..8c96acb 100755 --- a/scripts/rh-client.in +++ b/scripts/rh-client.in @@ -1,4 +1,5 @@ -#!/usr/bin/env guile +#!@GUILE@ \ +--no-auto-compile -e main -s !# (use-modules (simple-zmq) (config) @@ -28,19 +29,19 @@ (switch (name 'title) (synopsis "title of the new media") - (default "Foundation Trilogy") + (default "") (test string?) (character #t)) (switch (name 'author) (synopsis "author of the new media") - (default "Isaac Asimov") + (default "") (test string?) (character #t)) (switch (name 'location) (synopsis "location of the new media") - (default "https://openlibrary.org/books/OL20930675M/The_foundation_trilogy") + (default "") (test string?) (character #t)) (switch @@ -62,6 +63,10 @@ (configuration (name 'consume) (synopsis "remove the next media from the heap") + (wanted '((keywords . (service-socket))))) + (configuration + (name 'shutdown) + (synopsis "shutdown the heap") (wanted '((keywords . (service-socket))))))) (directory (list (in-home ".reading-heap/") (path (given @@ -70,7 +75,11 @@ "/.config")) "/reading-heap/")) (eager? #t)))) - (parser sexp-parser))) + (parser sexp-parser) + (copyright @COPYRIGHT@) + (version @HVERSION@) + (license @LICENSE@) + (author @AUTHOR@))) (define context (zmq-create-context)) @@ -78,7 +87,7 @@ (define (client-setup sock) (zmq-connect client-socket sock)) - + (define (rh-client-next) (zmq-send client-socket "next") (let ((msg (zmq-receive-bytevector client-socket 1500))) @@ -96,6 +105,10 @@ (zmq-send client-socket "consume") (display (zmq-receive client-socket 1500))) +(define (rh-client-shutdown) + (zmq-send client-socket "shutdown") + (display (zmq-receive client-socket 1500))) + (define (json-from-args priority title author location) (scm->json-string `(("priority" . ,priority) ("title" . ,title) @@ -118,6 +131,9 @@ ((string=? (cadr (full-command options)) "consume") (client-setup (option-ref options 'service-socket)) (rh-client-consumed)) + ((string=? (cadr (full-command options)) "shutdown") + (client-setup (option-ref options 'service-socket)) + (rh-client-shutdown)) (#t (emit-help options))))) (main (command-line)) diff --git a/scripts/rh-server.in b/scripts/rh-server.in index 9749ec2..a9dd758 100755 --- a/scripts/rh-server.in +++ b/scripts/rh-server.in @@ -1,4 +1,5 @@ -#!/usr/bin/env guile +#!@GUILE@ \ +--no-auto-compile -e main -s !# (use-modules (srfi srfi-1) (config) @@ -38,7 +39,7 @@ (character #f)) (switch (name 'serve) - (synopsis "server the media heap") + (synopsis "serve the media heap") (default #f) (test boolean?) (character #t)) @@ -51,16 +52,17 @@ "/reading-heap/")) (eager? #t)))) (parser sexp-parser) - (copyright '(2023)) - (version "0.1") - (license agpl3+) - (author "Christopher R. Nelson"))) + (copyright @COPYRIGHT@) + (version @HVERSION@) + (license @LICENSE@) + (author @AUTHOR@))) (define (main cmd-line) (let ((options (getopt-config-auto cmd-line config))) (when (option-ref options 'write) (options-write options)) - (when (option-ref options 'serve) + (when (or (option-ref options 'serve) + (not (option-ref options 'write))) (let* ((media (filetree->media-list (option-ref options 'media-library))) (priorities (map media-priority media)) (heap (fold heap-insert 'E priorities media))) |