X-Git-Url: https://code.consxy.com/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fprocessor.lisp;h=3f5954f09b794479861cf2fcae9ef50d1181fdd1;hb=88b07c40f1176869b4ed1b7188724c64753ee607;hp=0d6ec1ec075a258699aa69c91370163f518f4fd0;hpb=92a8cc8928e1f5d6aa13708b35cb4551aa736a37;p=candle diff --git a/src/main/processor.lisp b/src/main/processor.lisp index 0d6ec1e..3f5954f 100644 --- a/src/main/processor.lisp +++ b/src/main/processor.lisp @@ -1,14 +1,62 @@ +; Copyright 2022 Frank Duncan (frank@consxy.com) under AGPL3. See distributed LICENSE.txt. (in-package #:candle) (defvar *mutex* (sb-thread:make-mutex)) (defvar *waitq* (sb-thread:make-waitqueue)) -(defvar *job-system*) -(defgeneric process-job-in-system (job-system job)) -(defgeneric shutdown-system (job-system)) +(defvar *job-system* nil + "*JOB-SYSTEM* + +VALUE TYPE: + + A keyword + +INITIAL VALUE: + + NIL + +DESCRIPTION: + + The job system the server is running under. When implementing a job + system, the generics PROCESS-JOB-IN-SYSTEM and SHUTDOWN-SYSTEM must + be implemented. Is set by the command line when the server is started.") + +(defgeneric process-job-in-system (job-system job) + (:documentation + "PROCESS-JOB-IN-SYSTEM JOB-SYSTEM JOB => SUCCESS, LOG + +ARGUMENTS AND VALUES: + + JOB-SYSTEM: a keyword representing an installed system + JOB: A job to be run + SUCCESS: A boolean, whether the job was successful + LOG: The log from the job + +DESCRIPTION: + + Runs a job in the specified system. The code will be checked out, + so any defining system should copy the code from the job's project's + code dir to wherever it will run, and then ran `candle run` inside + that directory, capturing the output.")) + +(defgeneric shutdown-system (job-system) + (:documentation + "SHUTDOWN-SYSTEM JOB-SYSTEM => UNUSED + +ARGUMENTS AND VALUES: + + JOB-SYSTEM: a keyword representing an installed system + UNUSED: the result is unused + +DESCRIPTION: + + Shuts down the specified system. Sometimes this will be an empty + method, as the system requires no special shutdown instructions. + This is run when the candle server is shutdown for the job system + that's specified.")) (defun start-processor-thread () - (format t "Starting processor in ~(~A~) mode~%" *job-system*) + (log:info "Starting processor in ~(~A~) mode" *job-system*) (let* ((active t) (processor-thread @@ -28,7 +76,7 @@ :name "Processor"))) (push (lambda () - (format t "Shutting down processor thread~%") + (log:info "Shutting down processor thread") (setf active nil) (awaken-processor-thread) (sb-thread:join-thread processor-thread)