In breezewiki.rkt, start server in thread

This allows inspecting the program state using
(enter! "breezewiki.rkt") in the REPL.
This commit is contained in:
Cadence Ember 2022-09-01 14:55:25 +12:00
parent 8754273acf
commit 13c1b0636b
Signed by untrusted user: cadence
GPG key ID: BC1C2C61CF521B17

View file

@ -24,10 +24,13 @@
(set-reload-poll-interval! #f)) (set-reload-poll-interval! #f))
(reload!) (reload!)
(define ch (make-channel))
(define (start)
(serve/launch/wait (serve/launch/wait
#:listen-ip (if (config-true? 'debug) "127.0.0.1" #f) #:listen-ip (if (config-true? 'debug) "127.0.0.1" #f)
#:port (string->number (config-get 'port)) #:port (string->number (config-get 'port))
(λ (quit) (λ (quit)
(channel-put ch (lambda () (semaphore-post quit)))
(sequencer:make (sequencer:make
(pathprocedure:make "/" page-home) (pathprocedure:make "/" page-home)
(pathprocedure:make "/proxy" page-proxy) (pathprocedure:make "/proxy" page-proxy)
@ -35,4 +38,6 @@
(filter:make #rx"^/[a-z-]+/wiki/.+$" (lift:make page-wiki)) (filter:make #rx"^/[a-z-]+/wiki/.+$" (lift:make page-wiki))
(filter:make #rx"^/[a-z-]+/search$" (lift:make page-search)) (filter:make #rx"^/[a-z-]+/search$" (lift:make page-search))
static-dispatcher static-dispatcher
(lift:make page-not-found)))) (lift:make page-not-found)))))
(define server-t (thread start))
(define quit (channel-get ch))