(defvar *options*
'((:name :help :short "h" :long "help" :description "Print this usage.")
(:name :port :short "p" :long "port" :takes-argument t :variable-name "PORT"
- :description "Port on which to listen for commands. Defaults to 25004")))
+ :description "Port on which to listen for commands. Defaults to 25004")
+ (:name :port :long "candle-dir" :takes-argument t :variable-name "DIR"
+ :description "Directory for candle related data. Will be created if does not exist. Defaults to /opt/candle/")))
(defun usage ()
(format t "~A"
(opera:option-present :port options)
(parse-integer (opera:option-argument :port options) :junk-allowed t))
25004)))
+ (setf candle:*candle-dir*
+ (if (opera:option-present :port options)
+ (opera:option-argument :port options)
+ "/opt/candle/"))
(format t "Starting server on port ~A~%" port)
(candle:server port nil)))))
(in-package #:candle)
+(defvar *candle-dir*)
+
(lame-db:defdbstruct project name src)
(lame-db:defdbstruct job status sha when-run (project :join project))
(defpackage #:candle (:use :cl)
- (:export #:server #:add-project #:add-job #:run))
+ (:export #:server #:add-project #:add-job #:run #:*candle-dir*))
(defpackage #:candle-cli (:use :cl) (:export :run))
(in-package #:candle)
(defun server (port &optional (background t))
- (lame-db:load-known-dbs "/home/herbie/.lame-db/data")
- (sb-thread:make-thread
- (lambda ()
- (do () (nil)
- (progn
- (sleep (* 5 60))
- (lame-db:save-known-dbs "/home/herbie/.lame-db/data"))))
- :name "Save Thread")
- (communication:start-listener port background))
+ (when (not *candle-dir*) (error "Need a candle dir"))
+ (let
+ ((data-dir (format nil "~Adata" *candle-dir*)))
+ (ensure-directories-exist *candle-dir*)
+ (ensure-directories-exist data-dir)
+ (lame-db:load-known-dbs data-dir)
+ (sb-thread:make-thread
+ (lambda ()
+ (do () (nil)
+ (progn
+ (sleep (* 5 60))
+ (lame-db:save-known-dbs data-dir))))
+ :name "Save Thread")
+ (communication:start-listener port background)))
(defun add-project (name src)
(when