All pastes #256367 Raw Edit

Miscellany

public text v1 · immutable
#256367 ·published 2006-11-24 03:17 UTC
rendered paste body
function stat_logfile()
{
     awk '/Modify/ {print $3}' <<< "$(stat "$LOG_FILE")"
}

function get_line_count()
{
awk 'END{print NR}' "$LOG_FILE"
}

function check_stall()
{
    newlines=$(stat_logfile)
    while ps -p $(</tmp/tcode.pid) >/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 "*** transcode appears to be stalled ***"
            echo "*** We are going to send transcode a HUP and hope for the best ***"
            # make sure pid still active
            if $(ps -p $(</tmp/tcode.pid) >/dev/null); then
                $(kill -0 $(</tmp/tcode.pid) > /dev/null 2>&1) && kill -HUP     $(</tmp/tcode.pid)
            echo
        fi
    done
}