From f20aa31a7259407d960bdfc7d914441223e89ec5 Mon Sep 17 00:00:00 2001 From: Leo Butler Date: Thu, 12 May 2022 11:47:58 -0500 Subject: [PATCH] ffmpeg-myth1, ffmpeg-myth0 update ffmpeg-myth1: check the recording basename of the rec and tr-rec, if they are equal, don't schedule a deletion ffmpeg-myth0: institute an error handler around ffmpeg-myth1 ffmpeg-myth-do-pending-jobs: institute job control to prevent a collision --- ffmpeg-myth.scm | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/ffmpeg-myth.scm b/ffmpeg-myth.scm index a0b8511..a809c94 100755 --- a/ffmpeg-myth.scm +++ b/ffmpeg-myth.scm @@ -657,21 +657,34 @@ (mysql-start-transaction "") (mythconverg-update-recorded-seek-table tr-rec) (mythconverg-update-recordedmarkup-table tr-rec) - (mythconverg-update-ltbtranscodedtobedeleted rec) + (unless (equal? (recording-basename rec) (recording-basename tr-rec)) + (mythconverg-update-ltbtranscodedtobedeleted rec)) ;; mysql-commit in this step (mythconverg-update-recorded-table rec tr-rec) (mythconverg-execute mysql-cmd) (list rec tr-rec)) (lambda (key . args) (list rec tr-rec 'error))))) +(define (ffmpeg-myth0 chanid starttime cut-or-skip) + (catch #t + ;; thunk + (lambda () (ffmpeg-myth1 chanid starttime cut-or-skip)) + ;; handler + (lambda (key . rest) (simple-format #t "Error in ffmpeg-myth0: key=~a\nrest=~a\n" key rest) '()))) + (define (ffmpeg-myth-cut c-s) (ffmpeg-myth0 (car c-s) (cadr c-s) 'cut)) (define (ffmpeg-myth-skip c-s) (ffmpeg-myth0 (car c-s) (cadr c-s) 'skip)) (define* (ffmpeg-myth-do-pending-jobs #:optional (days 7)) - (let ((days (if (number? days) days 7))) - (map ffmpeg-myth-cut (mythconverg-pending-jobs days)))) + (let ((days (if (number? days) days 7)) + (how-many-running? (read-from-string (shell-command-to-string "ps -C ffmpeg-myth.scm -o pid=,time= | wc -l")))) + (cond ((eq? how-many-running? 1) + (map ffmpeg-myth-cut (mythconverg-pending-jobs days))) + (#t + (simple-format #t "ffmpeg-myth-do-pending-jobs: found ~a instances of ffmpeg-myth.scm running. Abort.\n" how-many-running?))))) + (define* (tmp-test #:optional (x 7)) (simple-format #t "~a\n" x) (force-output))