Slightly smarter encode failure reporting

This commit is contained in:
Neale Pickett 2022-01-09 20:23:05 -07:00
parent 16b5412875
commit 5ee0655e6e
2 changed files with 19 additions and 18 deletions

View File

@ -4,6 +4,9 @@
: ${OUTDIR:=/incoming} : ${OUTDIR:=/incoming}
export OUTDIR export OUTDIR
# This gets set to the directory containing what's currently running
: ${SCRIPTS:=$(dirname $0)}
log () { log () {
printf "\033[36m=== [%s] \033[0m %s\n" "$0" "$*" printf "\033[36m=== [%s] \033[0m %s\n" "$0" "$*"
} }

View File

@ -2,30 +2,28 @@
. $(dirname $0)/common.sh . $(dirname $0)/common.sh
run_in () {
(
cd $1; shift
setenv status "encoding"
"$@"
)
}
while sleep 2; do while sleep 2; do
echo "idle" > $OUTDIR/status.encoder echo "idle" > $OUTDIR/status.encoder
for mtype in audio video; do for mtype in audio video; do
ls $mtype | while read d; do ls $mtype | while read d; do
encode=/scripts/$mtype.encode.sh encode=$SCRIPTS/$mtype.encode.sh
workdir=$mtype/$d workdir=$mtype/$d
status=$(cd $workdir && getenv status) status=$(cd $workdir && getenv status)
[ "$status" = "read finished" ] || continue case "$status" in
"encoding")
(cd $workdir && setenv status "encode interrupted")
;;
"read finished")
echo "encoding" > $OUTDIR/status.encoder echo "encoding" > $OUTDIR/status.encoder
if ! run_in $workdir $encode; then (cd $workdir && setenv status "encoding")
if ! (cd $workdir && $encode); then
log "$encode failed" log "$encode failed"
(cd $workdir && setenv status "encode failed") (cd $workdir && setenv status "encode failed")
else else
rm -rf $workdir rm -rf $workdir
fi fi
;;
esac
done done
done done
done done