Finished refactor towards process-based workers.
This commit is contained in:
@ -1,26 +1,22 @@
|
||||
import docopt, logging, os, sequtils, tempfile
|
||||
import docopt, os, sequtils, tempfile
|
||||
|
||||
import strawboss/private/util
|
||||
import strawboss/configuration
|
||||
import strawboss/core
|
||||
import strawboss/server
|
||||
import strawboss/supervisor
|
||||
|
||||
let SB_VER = "0.1.0"
|
||||
let SB_VER = "0.2.0"
|
||||
|
||||
proc logProcOutput*(outMsg, errMsg: TaintedString, cmd: string) =
|
||||
let prefix = if cmd != nil: cmd else: ""
|
||||
if outMsg != nil: info prefix & "(stdout): " & outMsg
|
||||
if errMsg != nil: info prefix & "(stderr): " & errMsg
|
||||
if outMsg != nil: echo prefix & "(stdout): " & outMsg
|
||||
if errMsg != nil: echo prefix & "(stderr): " & errMsg
|
||||
|
||||
when isMainModule:
|
||||
|
||||
if logging.getHandlers().len == 0:
|
||||
logging.addHandler(newConsoleLogger())
|
||||
|
||||
var cfg = loadStrawBossConfig("strawboss.config.json")
|
||||
if not existsDir(cfg.artifactsRepo):
|
||||
info "Artifacts repo (" & cfg.artifactsRepo & ") does not exist. Creating..."
|
||||
echo "Artifacts repo (" & cfg.artifactsRepo & ") does not exist. Creating..."
|
||||
createDir(cfg.artifactsRepo)
|
||||
|
||||
cfg.artifactsRepo = expandFilename(cfg.artifactsRepo)
|
||||
@ -28,7 +24,6 @@ when isMainModule:
|
||||
let doc = """
|
||||
Usage:
|
||||
strawboss serve
|
||||
strawboss supervisor [-i <in-file>] [-o <out-file>]
|
||||
strawboss run <project> <step> [options]
|
||||
|
||||
Options
|
||||
@ -45,24 +40,25 @@ Options
|
||||
|
||||
let args = docopt(doc, version = "strawboss v" & SB_VER)
|
||||
|
||||
echo $args
|
||||
if args["run"]:
|
||||
|
||||
let req = RunRequest(
|
||||
projectName: $args["<project>"],
|
||||
stepName: $args["<step>"],
|
||||
buildRef: if args["--rreference"]: $args["<ref>"] else: nil,
|
||||
buildRef: if args["--reference"]: $args["--reference"] else: nil,
|
||||
forceRebuild: args["--force-rebuild"],
|
||||
workspaceDir: if args["--workspace"]: $args["<workspace>"] else: mkdtemp())
|
||||
|
||||
try:
|
||||
let summary = core.runStep(cfg, req, logProcOutput)
|
||||
# TODO: inspect result
|
||||
let status = core.runStep(cfg, req, logProcOutput)
|
||||
if status.state == "failed": raiseEx status.details
|
||||
echo "strawboss: build passed."
|
||||
except:
|
||||
fatal "strawboss: " & getCurrentExceptionMsg() & "."
|
||||
echo "strawboss: build FAILED: " & getCurrentExceptionMsg() & "."
|
||||
quit(QuitFailure)
|
||||
finally:
|
||||
if existsDir(req.workspaceDir): removeDir(req.workspaceDir)
|
||||
|
||||
info "strawboss: build passed"
|
||||
|
||||
elif
|
||||
elif args["serve"]: server.start(cfg)
|
||||
|
||||
|
Reference in New Issue
Block a user