M database.lisp => database.lisp +0 -1
@@ 66,4 66,3 @@
(get-path (get-title-by-id parent)))
`(,(caar (clsql:select [title] :from [adj_list] :where [= [title] title]))))))
-(connect)
M packages.lisp => packages.lisp +3 -2
@@ 5,7 5,8 @@
(defpackage wikisophy.database
(:use :cl)
(:export :insert-path
- :get-path))
+ :get-path :connect))
(defpackage wikisophy.server
- (:use :cl :wikisophy.database))
+ (:use :cl :wikisophy.database)
+ (:export :main))
M server.lisp => server.lisp +23 -1
@@ 13,4 13,26 @@ philosophy in json format."
(cl-json:encode-json-to-string (get-path query))))))
(defvar *server* (make-instance 'hunchentoot:easy-acceptor :port 4242))
-(hunchentoot:start *server*)
+
+(defun init ()
+ (hunchentoot:start *server*))
+
+(defun main ()
+ (wikisophy.database:connect)
+ (init) ;; our start-app, for example clack:clack-up
+ ;; let the webserver run.
+ ;; warning: hardcoded "hunchentoot".
+ (handler-case (bt:join-thread (find-if (lambda (th)
+ (search "hunchentoot" (bt:thread-name th)))
+ (bt:all-threads)))
+ ;; Catch a user's C-c
+ (#+sbcl sb-sys:interactive-interrupt
+ #+ccl ccl:interrupt-signal-condition
+ #+clisp system::simple-interrupt-condition
+ #+ecl ext:interactive-interrupt
+ #+allegro excl:interrupt-signal
+ () (progn
+ (format *error-output* "Aborting.~&")
+ (hunchentoot:stop *server*)
+ (uiop:quit)))
+ (error (c) (format t "Woops, an unknown error occured:~&~a~&" c))))
M wikisophy.asd => wikisophy.asd +3 -0
@@ 15,6 15,9 @@
:description "Web application for generating paths to the philosophy
article in wikipedia."
:serial t
+ :build-operation "program-op"
+ :build-pathname "out/wikisophy.run"
+ :entry-point "wikisophy.server:main"
:depends-on (:hunchentoot
:drakma
:cl-json