deferred tasks don't fail

This commit is contained in:
Felix Lohmeier 2022-04-06 21:11:08 +02:00 committed by GitHub
parent fceca60918
commit d35b679f6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 7 deletions

View File

@ -14,9 +14,10 @@ tasks:
default: default:
desc: run workflow in batch mode desc: run workflow in batch mode
cmds: cmds:
- defer: { task: stop } # will always be executed last - defer: { task: cleanup } # will always be executed last
- task: start - task: start
- task: example - task: example
- task: check
sources: sources:
- Taskfile.yml - Taskfile.yml
- input/** - input/**
@ -48,17 +49,20 @@ tasks:
"${OPENREFINE_APPDIR}/client" example \ "${OPENREFINE_APPDIR}/client" example \
--output output/deduped.tsv --output output/deduped.tsv
stop: check:
- defer: rm -rf "${OPENREFINE_TMPDIR}" - | # check log file for any warnings
if grep -i 'exception\|error' "${OPENREFINE_TMPDIR}/log.txt"
then echo 1>&2 "log contains warnings!"; echo; cat "${OPENREFINE_TMPDIR}/log.txt"; exit 1
fi
cleanup:
- | # print stats and kill OpenRefine immediately - | # print stats and kill OpenRefine immediately
PID="$(lsof -t -i:${OPENREFINE_PORT})" PID="$(lsof -t -i:${OPENREFINE_PORT})"
echo "used $(($(ps --no-headers -o rss -p "$PID") / 1024)) MB RAM" echo "used $(($(ps --no-headers -o rss -p "$PID") / 1024)) MB RAM"
echo "used $(ps --no-headers -o cputime -p "$PID") CPU time" echo "used $(ps --no-headers -o cputime -p "$PID") CPU time"
kill -9 $PID kill -9 $PID
- | # check log file for any warnings - | # delete temporary files
if grep -i 'exception\|error' "${OPENREFINE_TMPDIR}/log.txt" rm -rf "${OPENREFINE_TMPDIR}"
then echo 1>&2 "log contains warnings!"; echo; cat "${OPENREFINE_TMPDIR}/log.txt"; exit 1
fi
install: install:
desc: install OpenRefine and openrefine-client into subdirectory ${OPENREFINE_APPDIR} desc: install OpenRefine and openrefine-client into subdirectory ${OPENREFINE_APPDIR}