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))
11 (defpackage #:candle-server-cli (:use #:common-lisp))
12 (in-package #:candle-server-cli)
15 '((:name :help :short "h" :long "help" :description "Print this usage.")
16 (:name :port :short "p" :long "port" :takes-argument t :variable-name "PORT"
17 :description "Port on which to listen for commands. Defaults to 25004")
18 (:name :dir :long "candle-dir" :takes-argument t :variable-name "DIR"
19 :description "Directory for candle related data. Will be created if does not exist. Defaults to /opt/candle/")
20 (:name :system :long "system" :takes-argument t :variable-name "SYSTEM"
21 :description "System on which to run jobs. Currently available are local and aws. Defaults to local.")))
28 "Starts a candle continuous integration server. Use 'candle' to interact with the server.")))
30 (multiple-value-bind (options remaining-args error) (opera:process-arguments *options* (cdr sb-ext:*posix-argv*))
32 ((opera:option-present :help options) (usage))
34 (format *error-output* "Don't understand ~A. See 'candle-server -h'~%" (car remaining-args))
35 (sb-ext:exit :code 1))
36 ((and (opera:option-present :port options) (not (parse-integer (opera:option-argument :port options) :junk-allowed t)))
37 (format *error-output* "--port requires a number. See 'candle-server -h'~%"))
41 (opera:option-present :port options)
42 (parse-integer (opera:option-argument :port options) :junk-allowed t))
44 (setf candle:*job-system*
45 (if (opera:option-present :system options)
46 (intern (string-upcase (opera:option-argument :system options)) :keyword)
49 ((*error-output* (make-broadcast-stream)))
50 (case candle:*job-system*
51 (:aws (asdf:load-system :candle-aws))
52 (:local (asdf:load-system :candle-local))))
53 (setf candle:*candle-dir*
54 (if (opera:option-present :dir options)
55 (opera:option-argument :dir options)
57 (format t "Starting server on port ~A~%" port)
58 (candle:server port nil)))))