Fixed daemon modes

This commit is contained in:
louwrentius 2011-12-25 03:39:46 +00:00
parent ec1d542ab6
commit c78896892b
1 changed files with 33 additions and 30 deletions

63
ppss
View File

@ -66,7 +66,10 @@ 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 FAILED_ITEMS_COUNTER=0
QUIET="0" if [ -z "$QUIET" ]
then
QUIET="0"
fi
STOP="0" # STOP job. STOP="0" # STOP job.
MAX_DELAY="0" # MAX DELAY between jobs. MAX_DELAY="0" # MAX DELAY between jobs.
MAX_LOCK_DELAY="9" # MAX_LOCK_DELAY="9" #
@ -214,6 +217,9 @@ showusage_basic () {
echo -e " for new items and process them. Read the manual how to use this!" echo -e " for new items and process them. Read the manual how to use this!"
echo -e " See --help for important additional options regarding daemon mode." echo -e " See --help for important additional options regarding daemon mode."
echo echo
echo -e "--disable-inotify Linux users can use real-time inotify filesystem events when using"
echo -e " daemon mode. Requires inotify-tools. Enabled by default if available."
echo
echo -e "--no-recursion|-r By default, recursion of directories is enabled when the -d option is " echo -e "--no-recursion|-r By default, recursion of directories is enabled when the -d option is "
echo -e " used. If this is not prefered, this can be disabled with this option " echo -e " used. If this is not prefered, this can be disabled with this option "
echo -e " Only files within the specified directory will be processed." echo -e " Only files within the specified directory will be processed."
@ -470,43 +476,41 @@ is_var_empty () {
detect_source_dir_nfs_exported () { detect_source_dir_nfs_exported () {
log DEBUG "Executing $FUNCNAME" #log DEBUG "Executing $FUNCNAME"
if [ -e /etc/exports ] NFS=0
then NFS_MOUNTED_FS=`mount | grep ":" | cut -d ":" -f 2 | awk '{ print $3 }'`
log DEBUG "NFS /etc/exports found."
NFS=0 for mount in $NFS_MOUNTED_FS
EXPORTS=`cat /etc/exports | grep ^/ | awk '{ print $1 }'` do
for export in $EXPORTS #
# If this for loop matches anything, the SRC_DIR is NFS exported.
# inotify does not play well with NFS. So it must be disabled.
#
DIRECTORY="$SRC_DIR"
while true
do do
# #log DEBUG "NFS TEST: $mount vs. $DIRECTORY"
# If this for loop matches anything, the SRC_DIR is NFS exported. if [ ! "$DIRECTORY" = "/" ] && [ ! "$DIRECTORY" = "." ]
# inotify does not play well with NFS. So it must be disabled. then
# if [ "$mount" = "$DIRECTORY" ]
DIRECTORY=`dirname "$SRC_DIR"`
while true
do
if [ ! "$DIRECTORY" = "/" ] && [ ! "$DIRECTORY" = "." ]
then then
if [ "$export" = "$DIRECTORY" ] NFS=1
then
NFS=1
break
fi
else
break break
fi fi
DIRECTORY=`dirname "$DIRECTORY"` else
done break
fi
DIRECTORY=`dirname "$DIRECTORY"`
done done
fi done
if [ "$NFS" = "1" ] if [ "$NFS" = "1" ]
then then
log INFO "Source directory is NFS exported. Disabling inotify." #log DEBUG "Source directory is NFS exported. Disabling inotify."
return 1 return 1
else else
log INFO "Source directory is NOT NFS exported. Enabling inotify." #log DEBUG "Source directory is NOT NFS exported. Enabling inotify."
return 0 return 0
fi fi
} }
@ -2537,13 +2541,12 @@ terminate_listener () {
} }
inotify_listener () { inotify_listener () {
inotifywait "$SRC_DIR" -m -e close -q --format '%w%f' | \ inotifywait "$SRC_DIR" -m -e close -q --format '%w%f' | \
while read -r line while read -r line
do do
if [ ! -d "$line" ] if [ ! -d "$line" ]
then then
echo "$line" > "$FIFO" echo "$line" >> "$FIFO"
fi fi
done done
} }