feat(build): Configure ASDF program-op with entrypoint

This commit is contained in:
Vincent Ambo 2017-12-26 13:48:43 +01:00
parent abe8419b03
commit 5579ca7d6c
2 changed files with 18 additions and 2 deletions

View file

@ -20,6 +20,8 @@
:components ((:module "src"
:components
((:file "gemma"))))
:build-operation program-op
:entry-point "gemma::entrypoint"
:description "Gemma is a household task management system"
:long-description
#.(read-file-string

View file

@ -12,7 +12,8 @@
:local-time
:cl-json)
(:import-from :sb-posix :getenv)
(:shadowing-import-from :sb-posix :getcwd))
(:shadowing-import-from :sb-posix :getcwd)
(:export :start-gemma :config :entrypoint))
(in-package :gemma)
;; TODO: Store an average of how many days it was between task
@ -121,6 +122,8 @@ maximum interval."
(:remaining . ,(days-remaining task))))
(defun start-gemma ()
(in-package :gemma)
;; Load configuration
(load (pathname (or (getenv "GEMMA_CONFIG")
"/etc/gemma/config.lisp")))
@ -149,6 +152,18 @@ maximum interval."
(complete-task key)
(encode-json-to-string (response-for (get-task key))))))
(defun entrypoint ()
"This function serves as the entrypoint for ASDF-built executables.
It joins the Hunchentoot server thread to keep the process running
for as long as the server is alive."
(start-gemma)
(sb-thread:join-thread
(find-if (lambda (th)
(string= (sb-thread:thread-name th)
(format nil "hunchentoot-listener-*:~A" *gemma-port*)))
(sb-thread:list-all-threads))))
;; Experimentation / testing stuff
(defun randomise-completion-times ()
@ -166,4 +181,3 @@ maximum interval."
(cl-prevalence:find-all-objects *p-tasks* 'task)))
;; (randomise-completion-times)