Skip to content

Instantly share code, notes, and snippets.

@coetry
Created February 25, 2019 16:58
Show Gist options
  • Save coetry/ccbd98bb4aa6abe8d5b9b28267d0cc57 to your computer and use it in GitHub Desktop.
Save coetry/ccbd98bb4aa6abe8d5b9b28267d0cc57 to your computer and use it in GitHub Desktop.
simple hunchentoot server
(ql:quickload :clack)
(ql:quickload :bordeaux-threads)
(defun main (&rest argv)
(declare (ignorable argv))
(defvar *handler*
(clack:clackup
(lambda (env)
'(200 (:content-type "text/plain") ("alhamdulilLah")))))
(handler-case (bordeaux-threads:join-thread
(find-if (lambda (th)
(search "hunchentoot" (bordeaux-threads:thread-name th)))
(bordeaux-threads: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.~&")
(clack:stop *server*)
(uiop:quit)))
(error (c) (format t "Woops, an unknown error occured:~&~a~&" c))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment