|
@@ -1,8 +1,11 @@
|
1
|
1
|
(ql:quickload :coleslaw)
|
2
|
2
|
(ql:quickload :hunchentoot)
|
|
3
|
+(ql:quickload :cl-inotify) ; Had to apt-get install libfixposix-dev
|
|
4
|
+(ql:quickload :iterate)
|
|
5
|
+(ql:quickload :bordeaux-threads)
|
3
|
6
|
|
4
|
7
|
(defpackage :azrazalea-net
|
5
|
|
- (:use cl)
|
|
8
|
+ (:use cl iterate cl-inotify bordeaux-threads)
|
6
|
9
|
(:export build-coleslaw start-server stop-server deploy))
|
7
|
10
|
|
8
|
11
|
(in-package :azrazalea-net)
|
|
@@ -12,13 +15,36 @@
|
12
|
15
|
was started in is the site directory."
|
13
|
16
|
(coleslaw:main *default-pathname-defaults*))
|
14
|
17
|
|
|
18
|
+(defun watch-recursive (things)
|
|
19
|
+ (iter
|
|
20
|
+ (with inotify = (make-inotify))
|
|
21
|
+ (with flags = '(:create :modify :delete))
|
|
22
|
+ (for dir in things)
|
|
23
|
+ (watch inotify dir flags)
|
|
24
|
+ (iter (for subdir in (uiop:subdirectories dir))
|
|
25
|
+ (watch inotify subdir flags))
|
|
26
|
+ (finally (do-events (event inotify :blocking-p t)
|
|
27
|
+ (build-coleslaw)))))
|
15
|
28
|
|
16
|
|
-(let ((acceptor (make-instance 'hunchentoot:easy-acceptor :document-root (merge-pathnames "dist/") :port 4242)))
|
|
29
|
+(let ((acceptor (make-instance 'hunchentoot:easy-acceptor :document-root (merge-pathnames "dist/") :port 4242))
|
|
30
|
+ (file-things (mapc
|
|
31
|
+ (lambda (name) (merge-pathnames name))
|
|
32
|
+ '("pages/"
|
|
33
|
+ "static/"
|
|
34
|
+ "posts/"
|
|
35
|
+ "themes/"
|
|
36
|
+ ".coleslawrc")))
|
|
37
|
+ (inotify-thread nil))
|
17
|
38
|
(defun start-server ()
|
18
|
39
|
"Starts a hunchentoot server that serves the site on port 4242"
|
|
40
|
+ (when inotify-thread (destroy-thread inotify-thread))
|
|
41
|
+ (setf inotify-thread (make-thread (lambda ()
|
|
42
|
+ (watch-recursive file-things)) :name "inotify"))
|
19
|
43
|
(hunchentoot:start acceptor))
|
20
|
44
|
(defun stop-server ()
|
21
|
45
|
"Stops a hunchentoot server that serves the site on port 4242"
|
|
46
|
+ (when inotify-thread (destroy-thread inotify-thread))
|
|
47
|
+ (setf inotify-thread nil)
|
22
|
48
|
(hunchentoot:stop acceptor)))
|
23
|
49
|
|
24
|
50
|
(defun deploy ()
|