about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2026-03-16 02:58:47 -0500
committerFrederick Muriuki Muriithi2026-03-16 02:58:47 -0500
commitc31dcecf5c1837dd6cd3689716b90121be0b9fbe (patch)
treeacdf12cbbadbc0d4fded3215dd7152c0e5bcbea8
parentd19fcd79a028e649cb8ab3e42f5796bc353309ed (diff)
downloadgn-guile-c31dcecf5c1837dd6cd3689716b90121be0b9fbe.tar.gz
Add runnable bin/gn-guile script to start the webserver
* README.md: Update the documentation on how to run the webserver.
* bin/gn-guile: New runnable script to start webserver.
* web/webserver.scm: Make into Guile/Scheme module and remove
  entry-point `main' function.
-rw-r--r--README.md4
-rwxr-xr-xbin/gn-guile38
-rw-r--r--web/webserver.scm78
3 files changed, 74 insertions, 46 deletions
diff --git a/README.md b/README.md
index d37dd06..2577c00 100644
--- a/README.md
+++ b/README.md
@@ -34,7 +34,7 @@ git remote add gn git.genenetwork.org:/home/git/public/gn-guile
 GNU Guile allows you to develop against a live running web server using emacs-geiser on port 1970. To try this fire up the web server from the `web` directory as
 
 ```sh
-guix shell -L ~/guix-bioinformatics --container --network --development --file=guix.scm -- guile -L . --fresh-auto-compile --listen=1970 -e main web/webserver.scm 8091
+guix shell -L ~/guix-bioinformatics --container --network --development --file=guix.scm -- guile -L . --fresh-auto-compile --listen=1970 -e main bin/gn-guile 8091
 ```
 
 By default the root points to the API:
@@ -55,7 +55,7 @@ We recommend checking the Guix documentation for manifests, channels and guix.sc
 To run a standalone server you should run without the listener on port 1970:
 
 ```
-guix shell -L ~/guix-bioinformatics --container --network --file=guix.scm -- guile -L . --fresh-auto-compile -e main web/webserver.scm 8091
+guix shell -L ~/guix-bioinformatics --container --network --file=guix.scm -- guile -L . --fresh-auto-compile -e main bin/gn-guile 8091
 ```
 
 ## Welcome to the world of interactive Lisp programming
diff --git a/bin/gn-guile b/bin/gn-guile
new file mode 100755
index 0000000..47bd259
--- /dev/null
+++ b/bin/gn-guile
@@ -0,0 +1,38 @@
+#!/usr/bin/env sh
+# -*- mode: scheme; -*-
+exec guile --no-auto-compile -e main -s "$0" "$@"
+!#
+
+;;; gn-guile --- GN Guile web service
+;;; Copyright © 2026 Frederick M. Muriithi <fredmanglis@gmail.com>
+;;;
+;;; This file is part of gn-guile
+;;;
+;;; gn-guile is free software: you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation, either version 3 of the License, or
+;;; (at your option) any later version.
+;;;
+;;; gn-guile is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;;; General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with gn-guile.  If not, see <https://www.gnu.org/licenses/>.
+
+(use-modules (config)
+             (web config)
+             (web gn-uri)
+             (web webserver))
+
+(define (main args)
+  (write (string-append "Starting Guile REST API " get-version " server!"))
+  (write args)
+  (newline)
+  (let* ((options (parse-cli-options args))
+         (listen (option-ref options 'port)))
+    (when (option-ref options 'write)
+      (options-write options))
+    (display `("listening on" ,listen))
+    (start-web-server "127.0.0.1" listen (cli-options->gn-guile-config options))))
diff --git a/web/webserver.scm b/web/webserver.scm
index 69f5098..8c909a5 100644
--- a/web/webserver.scm
+++ b/web/webserver.scm
@@ -1,36 +1,37 @@
-(use-modules (json)
-             (config)
-             (ice-9 match)
-             (ice-9 format)
-             (ice-9 iconv)
-             (ice-9 receive)
-             (ice-9 string-fun)
-             (ice-9 exceptions)
-             (srfi srfi-1)
-             (srfi srfi-11)
-             (srfi srfi-13)
-             (srfi srfi-19)
-             (srfi srfi-26)
-             (rnrs io ports)
-             (rnrs bytevectors)
-             (web http)
-             (web client)
-             (web request)
-             (web response)
-             (web uri)
-             (web server)
-             (gn cache memoize)
-             (web gn-uri)
-             (gn db sparql)
-             (gn data dataset)
-             (gn data species)
-             (gn data group)
-             (gn runner gemma)
-             (web sxml)
-             (web config)
-             (web view view)
-             (web view doc)
-             (web view markdown))
+(define-module (web webserver)
+  #:use-module (json)
+  #:use-module (ice-9 match)
+  #:use-module (ice-9 format)
+  #:use-module (ice-9 iconv)
+  #:use-module (ice-9 receive)
+  #:use-module (ice-9 string-fun)
+  #:use-module (ice-9 exceptions)
+  #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-11)
+  #:use-module (srfi srfi-13)
+  #:use-module (srfi srfi-19)
+  #:use-module (srfi srfi-26)
+  #:use-module (rnrs io ports)
+  #:use-module (rnrs bytevectors)
+  #:use-module (web http)
+  #:use-module (web client)
+  #:use-module (web request)
+  #:use-module (web response)
+  #:use-module (web uri)
+  #:use-module (web server)
+  #:use-module (gn cache memoize)
+  #:use-module (web gn-uri)
+  #:use-module (gn db sparql)
+  #:use-module (gn data dataset)
+  #:use-module (gn data species)
+  #:use-module (gn data group)
+  #:use-module (gn runner gemma)
+  #:use-module (web sxml)
+  #:use-module (web config)
+  #:use-module (web view view)
+  #:use-module (web view doc)
+  #:use-module (web view markdown)
+  #:export (start-web-server))
 
 (define (get-extension filename)
   (let ((dot-pos (string-rindex filename #\.)))
@@ -393,14 +394,3 @@ otherwise search for set/group data"
               'http
               (list #:addr (inet-pton AF_INET address)
                     #:port port)))
-
-(define (main args)
-  (write (string-append "Starting Guile REST API " get-version " server!"))
-  (write args)
-  (newline)
-  (let* ((options (parse-cli-options args))
-         (listen (option-ref options 'port)))
-    (when (option-ref options 'write)
-      (options-write options))
-    (display `("listening on" ,listen))
-    (start-web-server "127.0.0.1" listen (cli-options->gn-guile-config options))))