All pastes #256428 Raw Edit

Unnamed

public text v1 · immutable
#256428 ·published 2006-11-24 05:14 UTC
rendered paste body
function check_stall()
{
    PIDOF_TRANSCODE=$(</tmp/tcode.pid)
    newlines=$(stat_logfile)
    while ps -p $PIDOF_TRANSCODE >/dev/null; do
        # Check for transcode output every 10 seconds
        sleep 10
        age=$newage
        newage=$(stat_logfile)
        # If no new output, sleep 20s and check again
        [[ $newage = $age ]] && sleep 20 && newage=$(stat_logfile)
        # If still no new lines, send a HUP signal to transcode
        if [[ $newage == $age ]]; then
            echo; echo
            echo "*** transcode appears to be stalled ***"
            echo "*** We are going to send transcode a HUP and hope for the best ***"
            sleep 5
            $(kill -0 $PIDOF_TRANSCODE > /dev/null 2>&1) && kill -HUP $PIDOF_TRANSCODE
            echo
        fi
    done
}

function stat_logfile()
{
     awk '/Modify/ {print $3}' <<< "$(stat "$LOG_FILE")"
}