blob: 6c8b960dc847f9ae8ef5adcacc1ec0d937b22eff (
plain)
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
36
37
38
39
40
41
42
43
|
(in-package #:hito)
;;; --- Server Configuration ---
(defvar *app* nil
"The Hunchentoot acceptor instance.")
(defvar *port* 8080
"Port on which HITO listens.")
(defvar *static-directory*
(asdf:system-relative-pathname "hito" "static/")
"Path to static assets (CSS, images).")
;;; --- Static File Serving ---
(push (hunchentoot:create-folder-dispatcher-and-handler
"/static/" *static-directory*)
hunchentoot:*dispatch-table*)
;;; --- Server Lifecycle ---
(defun start (&key (port *port*))
"Start the HITO web server. Initializes the database if needed."
(when *app*
(format t "~&Server already running on port ~D. Stop it first.~%" *port*)
(return-from start nil))
;; Ensure DB is ready
(init-db)
(setf *app* (make-instance 'hunchentoot:easy-acceptor
:port port
:document-root *static-directory*))
(hunchentoot:start *app*)
(format t "~&HITO is running on port ~D.~%" port)
*app*)
(defun stop ()
"Stop the HITO web server."
(when *app*
(hunchentoot:stop *app*)
(setf *app* nil)
(format t "~&HITO stopped.~%")
t))
|