1 #!/usr/bin/sbcl --script
3 (setf *compile-print* nil)
5 (asdf:initialize-source-registry
6 `(:source-registry (:tree ,(car (directory "."))) :INHERIT-CONFIGURATION))
8 ((*error-output* (make-broadcast-stream)))
9 (asdf:load-system :candle))
10 (asdf:load-system :opera)
12 (defpackage #:candle-server-cli (:use #:common-lisp))
13 (in-package #:candle-server-cli)
16 '((:name :help :short "h" :long "help" :description "Print this usage.")
17 (:name :port :short "p" :long "port" :takes-argument t :variable-name "PORT"
18 :description "Port on which to listen for commands. Defaults to 25004")
19 (:name :dir :long "candle-dir" :takes-argument t :variable-name "DIR"
20 :description "Directory for candle related data. Will be created if does not exist. Defaults to /opt/candle/")
21 (:name :system :long "system" :takes-argument t :variable-name "SYSTEM"
22 :description "System on which to run jobs. Currently available are local and aws. Defaults to local.")))
29 "Starts a candle continuous integration server. Use 'candle' to interact with the server.")))
31 (multiple-value-bind (options remaining-args error) (opera:process-arguments *options* (cdr sb-ext:*posix-argv*))
33 ((opera:option-present :help options) (usage))
35 (format *error-output* "Don't understand ~A. See 'candle-server -h'~%" (car remaining-args))
36 (sb-ext:exit :code 1))
37 ((and (opera:option-present :port options) (not (parse-integer (opera:option-argument :port options) :junk-allowed t)))
38 (format *error-output* "--port requires a number. See 'candle-server -h'~%"))
42 (opera:option-present :port options)
43 (parse-integer (opera:option-argument :port options) :junk-allowed t))
45 (setf candle:*job-system*
46 (if (opera:option-present :system options)
47 (intern (string-upcase (opera:option-argument :system options)) :keyword)
49 (case candle:*job-system*
50 (:aws (asdf:load-system :candle-aws))
51 (:local (asdf:load-system :candle-local)))
52 (setf candle:*candle-dir*
53 (if (opera:option-present :dir options)
54 (opera:option-argument :dir options)
56 (format t "Starting server on port ~A~%" port)
57 (candle:server port nil)))))