Fixed daemon modes

This commit is contained in:
louwrentius 2011-12-25 03:39:46 +00:00
parent ec1d542ab6
commit c78896892b

29
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
if [ -z "$QUIET" ]
then
QUIET="0" 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,26 +476,25 @@ 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 ]
then
log DEBUG "NFS /etc/exports found."
NFS=0 NFS=0
EXPORTS=`cat /etc/exports | grep ^/ | awk '{ print $1 }'` NFS_MOUNTED_FS=`mount | grep ":" | cut -d ":" -f 2 | awk '{ print $3 }'`
for export in $EXPORTS for mount in $NFS_MOUNTED_FS
do do
# #
# If this for loop matches anything, the SRC_DIR is NFS exported. # If this for loop matches anything, the SRC_DIR is NFS exported.
# inotify does not play well with NFS. So it must be disabled. # inotify does not play well with NFS. So it must be disabled.
# #
DIRECTORY=`dirname "$SRC_DIR"` DIRECTORY="$SRC_DIR"
while true while true
do do
#log DEBUG "NFS TEST: $mount vs. $DIRECTORY"
if [ ! "$DIRECTORY" = "/" ] && [ ! "$DIRECTORY" = "." ] if [ ! "$DIRECTORY" = "/" ] && [ ! "$DIRECTORY" = "." ]
then then
if [ "$export" = "$DIRECTORY" ] if [ "$mount" = "$DIRECTORY" ]
then then
NFS=1 NFS=1
break break
@ -500,13 +505,12 @@ detect_source_dir_nfs_exported () {
DIRECTORY=`dirname "$DIRECTORY"` DIRECTORY=`dirname "$DIRECTORY"`
done done
done done
fi
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
} }