-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstartup.lisp
41 lines (34 loc) · 1.35 KB
/
startup.lisp
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
;; startup.lisp
;; ports that will be listened on localhost:
;;
;; *htoot-port* - Hunchentoot (via proxy)
;; *swank-port* - Swank (via ssh+Emacs)
(defparameter *htoot-port* 8080)
(defparameter *swank-port* 4005)
(defparameter *htoot-server* nil)
(defparameter *swank-server* nil)
(setq hunchentoot:*message-log-pathname* (pathname (posix-getenv "HT_LOG"))
hunchentoot:*dispatch-table* (list 'hunchentoot:dispatch-easy-handlers))
(defun sigterm-handler (sig code scp)
(declare (ignore sig code scp))
;; Shut down Swank and anyone else by terminating all threads
(dolist (thread (sb-thread:list-all-threads))
(unless (equal sb-thread:*current-thread* thread)
(sb-thread:terminate-thread thread)))
(sleep 1)
(sb-ext:quit))
(defun start-htoot ()
"Start a Hunchentoot server listening for connections."
(setf *htoot-server*
(hunchentoot:start
(make-instance 'hunchentoot:acceptor :port *htoot-port*)))
(format t "Hunchentoot server started on port ~S~%" *htoot-port*))
(defun start-swank ()
"Start a Swank server for SLIME."
(setf *swank-server*
(swank:create-server :style :spawn
:port *swank-port*
:coding-system "utf-8-unix"))
(format t "Swank server started on port ~S~%" *swank-port*))
(sb-sys:enable-interrupt sb-unix:sigterm #'sigterm-handler)
(start-htoot)