mirror of
http://gogs.blitter.com:3000/Russtopia/bacillus.git
synced 2024-06-18 06:47:10 +00:00
Added -w option to specify workdir
Renamed repo workdir/ to example_workdir/, bacillus_launch explicitly uses this for demo Signed-off-by: Russ Magee <rmagee@gmail.com>
This commit is contained in:
parent
aa93e54df1
commit
71c2148155
35
bacillus.go
35
bacillus.go
|
@ -554,13 +554,17 @@ func manualJobTriggersHTML(fullLogLink bool) (ret string) {
|
|||
// constructed w/param form, rather than a direct XHR to
|
||||
// launch endpoint
|
||||
// ===================
|
||||
if isParameterizedBuildScript(cmdMap[k]) {
|
||||
ret += fmt.Sprintf("<a class='xhrlink' title='Play Job with Parameters' href='%s?param'>[▹] %s [action %s]</a>\n",
|
||||
k, k, cmdMap[k])
|
||||
if _, e := os.Stat(strings.Replace(cmdMap[k], "..", jobHomeDir, -1)); e != nil {
|
||||
ret += fmt.Sprintf("-- job script %s not found --\n", cmdMap[k])
|
||||
} else {
|
||||
fn := strings.Replace(k, "-", "", -1)
|
||||
ret += fmt.Sprintf(`<a class='xhrlink' onclick='%s(); return false;' title='Play Job' href='%s'>[▸] %s [action %s]</a>`+"\n",
|
||||
fn, k, k, cmdMap[k])
|
||||
if isParameterizedBuildScript(cmdMap[k]) {
|
||||
ret += fmt.Sprintf("<a class='xhrlink' title='Play Job with Parameters' href='%s?param'>[▹] %s [action %s]</a>\n",
|
||||
k, k, cmdMap[k])
|
||||
} else {
|
||||
fn := strings.Replace(k, "-", "", -1)
|
||||
ret += fmt.Sprintf(`<a class='xhrlink' onclick='%s(); return false;' title='Play Job' href='%s'>[▸] %s [action %s]</a>`+"\n",
|
||||
fn, k, k, cmdMap[k])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -791,7 +795,7 @@ func execJob(j jobCtx) {
|
|||
dirTmp, _ := filepath.Abs(jobHomeDir)
|
||||
workDir, terr := ioutil.TempDir(dirTmp, fmt.Sprintf("bacillus_%s_%s_", j.jobOpts, j.jobTag))
|
||||
c.Dir = workDir
|
||||
jobID := strings.Split(workDir, "_")[3]
|
||||
jobID := workDir[strings.LastIndex(workDir, "_")+1:]
|
||||
var indent int64
|
||||
var indentStr string
|
||||
if indStyle == indStyleIndent || indStyle == indStyleBoth {
|
||||
|
@ -806,7 +810,12 @@ func execJob(j jobCtx) {
|
|||
var workerOutputFile *os.File
|
||||
consoleFName := "console.out"
|
||||
workerOutputPath = workDir + "/" + consoleFName
|
||||
workerOutputRelPath := fmt.Sprintf("%s/bacillus_%s_%s_%s/%s", jobHomeDir, j.jobOpts, j.jobTag, jobID, consoleFName)
|
||||
workerOutputRelPath := fmt.Sprintf("%s/bacillus_%s_%s_%s/%s",
|
||||
jobHomeDir,
|
||||
j.jobOpts,
|
||||
j.jobTag,
|
||||
jobID,
|
||||
consoleFName)
|
||||
if attachStdout {
|
||||
c.Stdout = os.Stdout
|
||||
c.Stderr = os.Stderr
|
||||
|
@ -838,9 +847,10 @@ func execJob(j jobCtx) {
|
|||
// by the top "/" endpoint to show recently active jobs (ie., those with
|
||||
// workdirs still present)
|
||||
//
|
||||
fmt.Fprintf(c.Stdout, "[r 255]\n") //nolint:errcheck
|
||||
fmt.Fprintf(c.Stdout, "%s\n", strings.Replace(workerOutputRelPath, "workdir/", "/workdir/fullconsole/", 1)) //nolint:errcheck
|
||||
fmt.Fprintf(c.Stdout, "%s\n", j.jobTag) //nolint:errcheck
|
||||
fmt.Fprintf(c.Stdout, "[r 255]\n") //nolint:errcheck
|
||||
fmt.Fprintf(c.Stdout, "%s\n",
|
||||
strings.Replace(workerOutputRelPath, jobHomeDir, "/"+jobHomeDir+"/fullconsole", 1)) //nolint:errcheck
|
||||
fmt.Fprintf(c.Stdout, "%s\n", j.jobTag) //nolint:errcheck
|
||||
|
||||
cerr := c.Start()
|
||||
if cerr != nil {
|
||||
|
@ -1355,6 +1365,7 @@ func main() {
|
|||
flag.BoolVar(&basicAuth, "auth", true, "enable basic http auth login (be sure to also set -u and -p)")
|
||||
flag.StringVar(&strUser, "u", httpAuthUser, "web UI and endpoint username")
|
||||
flag.StringVar(&strPasswd, "p", httpAuthPasswd, "web UI and endpoint password")
|
||||
flag.StringVar(&jobHomeDir, "w", "workdir", "workdir for jobs (relative to bacillus launch dir)")
|
||||
flag.BoolVar(&createRunlog, "c", false, "set true/1 to create new run.log, overwriting old one")
|
||||
flag.StringVar(&indStyle, "i", indStyleBoth, "job entry indicator style [none|indent|colour|both]")
|
||||
flag.IntVar(&runLogTailLines, "rl", 30, "Scroll length of runlog (set to 0 for no limit)")
|
||||
|
@ -1385,7 +1396,7 @@ func main() {
|
|||
|
||||
//log.Printf("Registering handler for /runlog page.\n")
|
||||
http.HandleFunc("/runlog", runLogHandler)
|
||||
jobHomeDir = "workdir"
|
||||
|
||||
// Each non-switch argument is taken to be an endpoint (job) descriptor
|
||||
// Syntax of an endpoint:
|
||||
// endpoint:jobOpts:EVAR1=val1,EVAR2=val2[,...,EVAR<n>=val<n>]:cmd
|
||||
|
|
|
@ -68,6 +68,7 @@ RUNLOG_LIVE_VIEW_LINES=${RUNLOG_LIVE_VIEW_LINES:-30}
|
|||
F=${F:-true} # show pipeline stages on finished job runlog entries
|
||||
JOBLIMIT=${JOBLIMIT:-"8"} # default, override to set
|
||||
DEMO=${DEMO:-false}
|
||||
WORKDIR=${WORKDIR:-"example_workdir"}
|
||||
|
||||
## If better log rotation is desired, use logrotate.
|
||||
if [ -e run"${PORT}".log ] && [ ${1:-"n"} == "-r" ]; then
|
||||
|
@ -90,7 +91,12 @@ fi
|
|||
##0 * * * * curl -s --netrc-file $HOME/bacillus-auth.txt https://bacillus.blitter.com/onPush-hkexsh-build >/dev/null 2>&1
|
||||
##
|
||||
|
||||
bacillus -D="${DEMO}" -F="${F}" -jl="${JOBLIMIT}" -a=:"${PORT}" -rl="${RUNLOG_LIVE_VIEW_LINES}" \
|
||||
bacillus -D="${DEMO}"\
|
||||
-w="${WORKDIR}"\
|
||||
-F="${F}"\
|
||||
-jl="${JOBLIMIT}"\
|
||||
-a=:"${PORT}"\
|
||||
-rl="${RUNLOG_LIVE_VIEW_LINES}" \
|
||||
-auth=${AUTH} -u=${AUTH_USER} -p=${AUTH_PASS} \
|
||||
onPush-bacillus-build:kD::"../bacillus_pushbuild.sh" \
|
||||
onPush-hkexsh-build:kD:FOO=bar,BAZ=buzz:"../hkexsh_pushbuild.sh" \
|
||||
|
|
5
example_workdir/00README.txt
Normal file
5
example_workdir/00README.txt
Normal file
|
@ -0,0 +1,5 @@
|
|||
# This is an example workdir to demonstrate bacillus.
|
||||
# You should create your own workdir beside this one, with
|
||||
# your own job scripts, and specify -w=<workdir> to point
|
||||
# your instance to that dir.
|
||||
|
Loading…
Reference in New Issue
Block a user