((*error-output* (make-broadcast-stream)))
(asdf:load-system :candle))
-(defpackage #:candle-server-cli (:use #:common-lisp))
-(in-package #:candle-server-cli)
-
-(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")
- (:name :dir :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/")
- (:name :system :long "system" :takes-argument t :variable-name "SYSTEM"
- :description "System on which to run jobs. Currently available are local and aws. Defaults to local.")))
-
-(defun usage ()
- (format t "~A"
- (opera:usage
- "candle-server"
- *options*
- "Starts a candle continuous integration server. Use 'candle' to interact with the server.")))
-
-(multiple-value-bind (options remaining-args error) (opera:process-arguments *options* (cdr sb-ext:*posix-argv*))
- (cond
- ((opera:option-present :help options) (usage))
- (remaining-args
- (format *error-output* "Don't understand ~A. See 'candle-server -h'~%" (car remaining-args))
- (sb-ext:exit :code 1))
- ((and (opera:option-present :port options) (not (parse-integer (opera:option-argument :port options) :junk-allowed t)))
- (format *error-output* "--port requires a number. See 'candle-server -h'~%"))
- (t
- (let
- ((port (or (and
- (opera:option-present :port options)
- (parse-integer (opera:option-argument :port options) :junk-allowed t))
- 25004)))
- (setf candle:*job-system*
- (if (opera:option-present :system options)
- (intern (string-upcase (opera:option-argument :system options)) :keyword)
- :local))
- (let
- ((*error-output* (make-broadcast-stream)))
- (case candle:*job-system*
- (:aws (asdf:load-system :candle-aws))
- (:local (asdf:load-system :candle-local))))
- (setf candle:*candle-dir*
- (if (opera:option-present :dir options)
- (opera:option-argument :dir options)
- "/opt/candle/"))
- (format t "Starting server on port ~A~%" port)
- (candle:server port nil)))))
+(candle-server-cli:run)
; vim:ft=lisp
(:file "run")
(:file "processor")
(:file "server")
- (:file "cli"))
+ (:file "cli")
+ (:file "server-cli"))
:depends-on (:herbie-utility :opera))
(asdf:defsystem candle-aws
#:candle-error #:candle-error-reason))
(defpackage #:candle-cli (:use :cl) (:export :run))
+(defpackage #:candle-server-cli (:use :cl) (:export :run))
(defpackage #:candle-aws (:use :cl))
(defpackage #:candle-local (:use :cl))
--- /dev/null
+(in-package #:candle-server-cli)
+
+(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")
+ (:name :dir :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/")
+ (:name :system :long "system" :takes-argument t :variable-name "SYSTEM"
+ :description "System on which to run jobs. Currently available are local and aws. Defaults to local.")))
+
+(defun usage ()
+ (format t "~A"
+ (opera:usage
+ "candle-server"
+ *options*
+ "Starts a candle continuous integration server. Use 'candle' to interact with the server.")))
+
+(defun run ()
+ (multiple-value-bind (options remaining-args error) (opera:process-arguments *options* (cdr sb-ext:*posix-argv*))
+ (cond
+ ((opera:option-present :help options) (usage))
+ (remaining-args
+ (format *error-output* "Don't understand ~A. See 'candle-server -h'~%" (car remaining-args))
+ (sb-ext:exit :code 1))
+ ((and (opera:option-present :port options) (not (parse-integer (opera:option-argument :port options) :junk-allowed t)))
+ (format *error-output* "--port requires a number. See 'candle-server -h'~%"))
+ (t
+ (let
+ ((port (or (and
+ (opera:option-present :port options)
+ (parse-integer (opera:option-argument :port options) :junk-allowed t))
+ 25004)))
+ (setf candle:*job-system*
+ (if (opera:option-present :system options)
+ (intern (string-upcase (opera:option-argument :system options)) :keyword)
+ :local))
+ (let
+ ((*error-output* (make-broadcast-stream)))
+ (case candle:*job-system*
+ (:aws (asdf:load-system :candle-aws))
+ (:local (asdf:load-system :candle-local))))
+ (setf candle:*candle-dir*
+ (if (opera:option-present :dir options)
+ (opera:option-argument :dir options)
+ "/opt/candle/"))
+ (format t "Starting server on port ~A~%" port)
+ (candle:server port nil))))))