From d5086b545d32e23f9c3118bf4094b3dcc98d6096 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 18 Aug 2020 20:41:10 +0200 Subject: Made --port also option. --- module/calp/entry-points/server.scm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/module/calp/entry-points/server.scm b/module/calp/entry-points/server.scm index f8262b76..e9d32916 100644 --- a/module/calp/entry-points/server.scm +++ b/module/calp/entry-points/server.scm @@ -2,6 +2,7 @@ :use-module (util) :use-module (util options) :use-module (util exceptions) + :use-module (util config) :use-module (srfi srfi-1) @@ -14,8 +15,11 @@ (define options '((port (value #t) (single-char #\p) - (description "Bind to TCP port, defaults to " (i 8080) ".")) + (description "Bind to TCP port, defaults to " (i 8080) "." + (br) "Can also be set through the config variable " + (i "port") ".")) (addr (value #t) + (description "Address to use, defaults to " (i "0.0.0.0") " for IPv4, and " (i "::") " for IPv6.") ) @@ -27,11 +31,15 @@ (description "Print this help.")))) +(define-config port 8080) + (define-public (main args) (define opts (getopt-long args (getopt-opt options))) - (define port (string->number (option-ref opts 'port "8080"))) (define addr (option-ref opts 'addr #f)) + (define port (or (and=> (option-ref opts 'port #f) + string->number) + (get-config 'port))) (define family (cond [(option-ref opts 'six #f) AF_INET6] [(option-ref opts 'four #f) AF_INET] @@ -61,6 +69,8 @@ (current-error-port)) ((@ (vcomponent instance) reload))))) + + (format #t "Starting server on ~a:~a~%I'm ~a, runing from ~a~%" addr port (getpid) (getcwd)) -- cgit v1.2.3