From d0308d089369486aa2ef952a193e7b475ca77e0a Mon Sep 17 00:00:00 2001 From: Dimakakos Dimos Date: Fri, 18 Sep 2020 20:09:44 +0300 Subject: [PATCH] Add: build instructions and main end-point --- database.lisp | 1 - packages.lisp | 5 +++-- server.lisp | 24 +++++++++++++++++++++++- wikisophy.asd | 3 +++ 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/database.lisp b/database.lisp index 2457753..746f9d8 100644 --- a/database.lisp +++ b/database.lisp @@ -66,4 +66,3 @@ (get-path (get-title-by-id parent))) `(,(caar (clsql:select [title] :from [adj_list] :where [= [title] title])))))) -(connect) diff --git a/packages.lisp b/packages.lisp index a14eaa6..caf112c 100644 --- a/packages.lisp +++ b/packages.lisp @@ -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)) diff --git a/server.lisp b/server.lisp index d0d7213..8fdd4c7 100644 --- a/server.lisp +++ b/server.lisp @@ -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)))) diff --git a/wikisophy.asd b/wikisophy.asd index 7ee19f7..93b13ab 100644 --- a/wikisophy.asd +++ b/wikisophy.asd @@ -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 -- 2.38.5