-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun.lisp
35 lines (31 loc) · 1.09 KB
/
run.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
(in-package :galton)
(defun cleanup-whitespace (string)
(if (stringp string)
(ppcre:regex-replace-all "\\s+" string " ")
string))
(defun maptree (function tree)
(if (atom tree)
(funcall function tree)
(mapcar (curry #'maptree function) tree)))
(defclass logging-acceptor (restas-acceptor)
()
(:default-initargs
:access-log-destination #p"access.log"
:message-log-destination #P"error.log"))
(defun run (form &rest args &key (port 8080))
;; ew...
(setf *default-pathname-defaults*
(make-pathname :name nil
:type nil
:defaults (asdf:system-definition-pathname :galton)))
(setf *form* (maptree #'cleanup-whitespace form))
(setf *results* (with-open-file (in (form :output)
:if-does-not-exist nil
:external-format :utf-8)
(when in
(read in))))
(setf *results-lock* (bt:make-lock "results lock"))
(apply #'start :galton
:port port
:acceptor-class 'logging-acceptor
args))