From 7956ca96a04be7ffd12264f43c914a590de09a3b Mon Sep 17 00:00:00 2001 From: Mikhail Novosyolov Date: Wed, 1 Sep 2021 14:23:37 +0300 Subject: [PATCH] convert unexpected errors to correct exit code for CUPS --- cups-backend-copy-raw.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cups-backend-copy-raw.sh b/cups-backend-copy-raw.sh index 91e824e..ced4886 100755 --- a/cups-backend-copy-raw.sh +++ b/cups-backend-copy-raw.sh @@ -6,7 +6,7 @@ # all artefacts of the meeting to /var/bigbluebutton/recording/raw/$meeting_id # and sends all that to a special worker which processes (converts) recordings. # All recordings are sent, even those where recording was not turned on, -# because it may have been not tunred on erroneously and so we still have +# because it may have been not turned on erroneously and so we still have # to keep the recording artefact. The storage of recordings will rotate them. # "Printer class" in CUPS may be used to load balance processing of recordings # to multiple workers. Printer Device URI can be used to show which "printer" @@ -39,6 +39,15 @@ CUPS_BACKEND_CANCEL=5 # Job failed, cancel job CUPS_BACKEND_RETRY=6 # Job failed, retry this job later CUPS_BACKEND_RETRY_CURRENT=7 # Job failed, retry this job immediately +# We use 'set -e', script may fail somewhere, +# make CUPS restart the job later if the error was unexpected +_trap_exit(){ + if [ $? != "$CUPS_BACKEND_FAILED" ]; then + exit "$CUPS_BACKEND_RETRY" + fi +} +trap '_trap_exit' EXIT + input="" case ${#} in