Skip to content

Commit 988db8b

Browse files
committed
Merge pull request #51 from pnathan/convert-to-lisp-server
Use Hunchentoot rather than Nginx to serve the web.
2 parents 4482527 + d8c231c commit 988db8b

File tree

4 files changed

+49
-3
lines changed

4 files changed

+49
-3
lines changed

Dockerfile

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
1-
from nginx
2-
copy _site/ /usr/share/nginx/html
1+
from davazp/quicksbcl
2+
run apt-get update
3+
run apt-get install -y libssl-dev
4+
expose 80
5+
6+
run sbcl --eval '(ql:update-all-dists :prompt nil)' --eval '(ql:quickload :hunchentoot)' --eval '(ql:quickload :local-time)' --non-interactive
7+
8+
copy source/ /opt/articulate-common-lisp/www
9+
copy _site/ /opt/articulate-common-lisp/www/static
10+
11+
cmd sbcl --load /opt/articulate-common-lisp/www/main.lisp --eval '(start)' --non-interactive

_data/nav.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,4 @@
5656
href: "/quicklisp.html"
5757

5858
- title: "Who?"
59-
href: "/about/"
59+
href: "/about.html"

about/index.html about.html

File renamed without changes.

source/main.lisp

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
(ql:quickload '( :hunchentoot :local-time))
2+
3+
(defvar *acceptor* nil "the hunchentoot acceptor")
4+
(format t "Articulating Common Lisp...~%")
5+
6+
(hunchentoot:define-easy-handler (release :uri "/api/release") ()
7+
(setf (hunchentoot:content-type*) "text/plain")
8+
(format t "A release of articulate-common-lisp is present!")
9+
(with-open-file (stream "/tmp/articulate-common-lisp.release" :direction :output :if-exists :overwrite :if-does-not-exist :create)
10+
(format stream "begin release @ ~a" (local-time:now)))
11+
"Release acknowledged. Grimoires under consultation.")
12+
13+
(defun start(&optional (fake-daemon t) &key (path nil) (port 80))
14+
(format t "Starting web server...~%")
15+
16+
(setf hunchentoot:*dispatch-table*
17+
(append
18+
hunchentoot:*dispatch-table*
19+
(list
20+
(hunchentoot:create-static-file-dispatcher-and-handler
21+
"/" (if path
22+
(concatenate 'string path "/index.html")
23+
#p"/opt/articulate-common-lisp/www/static/index.html"))
24+
(hunchentoot:create-folder-dispatcher-and-handler
25+
"/"
26+
(if path
27+
path
28+
#p"/opt/articulate-common-lisp/www/static/")))))
29+
30+
(setf *acceptor* (make-instance 'hunchentoot:easy-acceptor :port port))
31+
(hunchentoot:start *acceptor*)
32+
33+
(when fake-daemon
34+
(loop while t
35+
do
36+
(format t "~&~a - heartbeat...~%" (local-time:now))
37+
(sleep 5))))

0 commit comments

Comments
 (0)