PPSS now reports if items have failed

This commit is contained in:
louwrentius 2011-08-20 20:54:31 +00:00
parent 72e0c983d0
commit ed4c0bf554
1 changed files with 36 additions and 17 deletions

45
ppss
View File

@ -65,6 +65,7 @@ GLOBAL_COUNTER=1
LISTOFITEMS="$PPSS_DIR/INPUT_FILE-$PID" LISTOFITEMS="$PPSS_DIR/INPUT_FILE-$PID"
JOB_LOG_DIR="$PPSS_DIR/job_log" # Directory containing log files of processed items. JOB_LOG_DIR="$PPSS_DIR/job_log" # Directory containing log files of processed items.
LOGFILE="$PPSS_DIR/ppss-log-$PID.txt" # General PPSS log file. Contains lots of info. LOGFILE="$PPSS_DIR/ppss-log-$PID.txt" # General PPSS log file. Contains lots of info.
FAILED_ITEMS_COUNTER=0
QUIET="0" QUIET="0"
STOP="0" # STOP job. STOP="0" # STOP job.
MAX_DELAY="0" # MAX DELAY between jobs. MAX_DELAY="0" # MAX DELAY between jobs.
@ -74,8 +75,9 @@ LISTENER_PID=""
IFS_BACKUP="$IFS" IFS_BACKUP="$IFS"
CPUINFO="/proc/cpuinfo" CPUINFO="/proc/cpuinfo"
PROCESSORS="" PROCESSORS=""
START_KEY="$RANDOM$RANDOM$RANDOM" START_KEY="$RANDOM$RANDOM$RANDOM$RANDOM" # If this key is received by listener, start a new process
KILL_KEY="$RANDOM$RANDOM$RANDOM" # This is a signal to stop immediately and kill FAIL_KEY="$RANDOM$RANDOM$RANDOM$RANDOM" # if this key is received by listener, increase error count
KILL_KEY="$RANDOM$RANDOM$RANDOM$RANDOM" # This is a signal to stop immediately and kill PPSS
QUEUE="" QUEUE=""
INOTIFY="" INOTIFY=""
RECURSION="1" # all running processes. RECURSION="1" # all running processes.
@ -975,6 +977,7 @@ log () {
if [ "$TYPE" == "PRCNT" ] if [ "$TYPE" == "PRCNT" ]
then then
echo -en "\r$ECHO_MSG" echo -en "\r$ECHO_MSG"
#echo "$ECHO_MSG" # for debugging.
fi fi
} }
@ -2165,10 +2168,10 @@ commando () {
echo -e "Start date:\t$DATE" >> "$ITEM_LOG_FILE" echo -e "Start date:\t$DATE" >> "$ITEM_LOG_FILE"
echo -e "" >> "$ITEM_LOG_FILE" echo -e "" >> "$ITEM_LOG_FILE"
# #-->#
# The actual execution of the command as specified by #--># The actual execution of the command as specified by
# the -c option. #--># the -c option.
# #-->#
BEFORE=`get_time_in_seconds` BEFORE=`get_time_in_seconds`
`echo $COMMAND | grep -i '$ITEM' >> /dev/null 2>&1` `echo $COMMAND | grep -i '$ITEM' >> /dev/null 2>&1`
RETVAL="$?" RETVAL="$?"
@ -2190,6 +2193,8 @@ commando () {
if [ ! "$ERROR" == "0" ] if [ ! "$ERROR" == "0" ]
then then
mail_on_error "$ITEM" "$ITEM_LOG_FILE" mail_on_error "$ITEM" "$ITEM_LOG_FILE"
log DEBUG "Processing Item $ITEM failed."
echo "$FAIL_KEY" >> "$FIFO"
echo -e "Status:\t\tFAILURE" >> "$ITEM_LOG_FILE" echo -e "Status:\t\tFAILURE" >> "$ITEM_LOG_FILE"
else else
echo -e "Status:\t\tSUCCESS" >> "$ITEM_LOG_FILE" echo -e "Status:\t\tSUCCESS" >> "$ITEM_LOG_FILE"
@ -2384,12 +2389,19 @@ display_progress () {
if [ "$DAEMON" = "0" ] if [ "$DAEMON" = "0" ]
then then
SIZE_OF_INPUT=$(wc -l "$LISTOFITEMS" | awk '{ print $1 }') SIZE_OF_INPUT=$(wc -l "$LISTOFITEMS" | awk '{ print $1 }')
PERCENT=$((100 * $GLOBAL_COUNTER / $SIZE_OF_INPUT )) GC=0
if [ ! "$ACTIVE_WORKERS" == "0" ] && [ "$FINISHED" == "0" ] if [ ! "$GLOBAL_COUNTER" -gt "$SIZE_OF_INPUT" ]
then
GC="$GLOBAL_COUNTER"
else
GC="$SIZE_OF_INPUT"
fi
PERCENT=$((100 * $GC / $SIZE_OF_INPUT ))
if [ ! "$ACTIVE_WORKERS" == "0" ] # && [ "$FINISHED" == "0" ]
then then
if [ "$QUIET" == "0" ] if [ "$QUIET" == "0" ]
then then
log PRCNT "Currently $PERCENT percent complete. Processed $GLOBAL_COUNTER of $SIZE_OF_INPUT." log PRCNT "$PERCENT% complete. Processed $GC of $SIZE_OF_INPUT. Failed $FAILED_ITEMS_COUNTER/$SIZE_OF_INPUT."
show_eta show_eta
elif [ "$DAEMON" == "0" ] elif [ "$DAEMON" == "0" ]
then then
@ -2426,6 +2438,7 @@ terminate_listener () {
then then
echo echo
stop-ppss stop-ppss
log DSPLY "$FAILED_ITEMS_COUNTER failed items."
log DSPLY "Finished. Consult $JOB_LOG_DIR for job output." log DSPLY "Finished. Consult $JOB_LOG_DIR for job output."
#log DSPLY "Press ENTER to continue." #log DSPLY "Press ENTER to continue."
else else
@ -2595,16 +2608,15 @@ listen_for_job () {
while read event <& 42 while read event <& 42
do do
display_progress
log INFO "Current active workers is $ACTIVE_WORKERS" log INFO "Current active workers is $ACTIVE_WORKERS"
if [ "$event" = "$START_KEY" ] if [ "$event" == "$START_KEY" ]
then then
decrease_active_workers decrease_active_workers
log DEBUG "Got a 'start-key' event" log DEBUG "Got a 'start-key' event"
if [ "$DAEMON" = "0" ] if [ "$DAEMON" == "0" ]
then then
if get_item if get_item
then then
@ -2614,6 +2626,7 @@ listen_for_job () {
log DEBUG "No more new items..." log DEBUG "No more new items..."
if [ "$ACTIVE_WORKERS" = "0" ] if [ "$ACTIVE_WORKERS" = "0" ]
then then
display_progress
break break
else else
display_jobs_remaining display_jobs_remaining
@ -2623,7 +2636,10 @@ listen_for_job () {
log DEBUG "Daemon mode: a worker finished..." log DEBUG "Daemon mode: a worker finished..."
run_command run_command
fi fi
elif [ "$event" == "$FAIL_KEY" ]
then
((FAILED_ITEMS_COUNTER++))
log DEBUG "An item failed to process. $FAILED_ITEMS_COUNTER"
elif [ "$event" == "$KILL_KEY" ] elif [ "$event" == "$KILL_KEY" ]
then then
infanticide infanticide
@ -2633,6 +2649,9 @@ listen_for_job () {
stack_push "$event" stack_push "$event"
run_command run_command
fi fi
display_progress
done done
terminate_listener terminate_listener