X-Git-Url: https://code.consxy.com/gitweb/gitweb.cgi?p=candle;a=blobdiff_plain;f=src%2Fmain%2Fserver-cli.lisp;fp=src%2Fmain%2Fserver-cli.lisp;h=8947727afacc08415ad95066c6af0ee0e429bea6;hp=0000000000000000000000000000000000000000;hb=d7f08bad7f5d32edb80f2e1468eff32c50166a94;hpb=2a45e9d6f9b421e06095281ad47c127db3b8b476 diff --git a/src/main/server-cli.lisp b/src/main/server-cli.lisp new file mode 100644 index 0000000..8947727 --- /dev/null +++ b/src/main/server-cli.lisp @@ -0,0 +1,48 @@ +(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))))))