Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Feature Request: Re-Scan/inotify
26-04-2012, 17:44
Post: #11
RE: Feature Request: Re-Scan/inotify
(26-04-2012 17:00)simoncn Wrote:  
(26-04-2012 16:29)KoS Wrote:  hmm.. haven't realized the problem with the SIGHUP when exiting from a shell. you could use instead another signal for the restart of the daemon, e.g. SIGUSR1 or SIGUSR2 ?
That's a good idea, though I'd need to be careful not to confict with the use of these signals for other purposes, such as controlling LinuxThreads. I think the best approach would be to make the choice of 'reload' signal configurable, so that people could choose a signal that doesn't conflict with other usage in their environment.
as far as i know the SIGUSR1 and SIGUSR2 kill signals are explicitly for custom use of an application and no-one should expect anything specific happening when using this signals. so its up to the application to define the usage.
Find all posts by this user
Quote this message in a reply
30-04-2012, 14:55
Post: #12
RE: Feature Request: Re-Scan/inotify
i have created the following bash script to automatically restart my minim instance when files are added/deleted/modified:
Code:
#!/bin/sh
LOCK_FILE=/opt/minim/inotify.lck

restartminim() {
        while true; do
                if [ -e "$LOCK_FILE" ] ; then
                        if test `find "$LOCK_FILE" -mmin +1`
                        then
                                /opt/minim/restartminim.exp
                                rm $LOCK_FILE
                        fi
                fi
                sleep 60
        done
}

myinotifywait() {
        while inotifywait -q -r -e close_write,move,delete /media/upnp/Musik/; do
                touch $LOCK_FILE
        done
}

myinotifywait&
pid1=$!
echo "Myinotifywait spawned: $pid1"

restartminim&
pid2=$!
echo "Restartminim spawned: $pid2"

# Kill all sub-processes
trap "kill 0" SIGINT SIGTERM EXIT
wait

echo "finish."
Find all posts by this user
Quote this message in a reply
30-04-2012, 18:48
Post: #13
RE: Feature Request: Re-Scan/inotify
Thanks for sharing this!
Find all posts by this user
Quote this message in a reply
16-07-2012, 11:26
Post: #14
RE: Feature Request: Re-Scan/inotify
new version of the script:
Code:
#!/bin/sh
pdir=${0%`basename $0`}
lck_file=$pdir/`basename $0`.lck
log_file=$pdir/`basename $0`.log
ino_lck_file=$pdir/`basename $0`.inotify.lck
conf_file=$pdir/`basename $0`.conf

if [ -f $conf_file ]; then
        source $conf_file
else
        echo "ERROR: Can't locate $conf_file"
        exit 1
fi

# ------------------------------------------------------------
# Am I Running
# ------------------------------------------------------------
if [ -f "${lck_file}" ]; then

  # The file exists so read the PID
  # to see if it is still running  
  MYPID=`head -n 1 "${lck_file}"`  

  TEST_RUNNING=`ps -p ${MYPID} | grep ${MYPID}`

  if [ -z "${TEST_RUNNING}" ]; then
    # The process is not running  
    # Echo current PID into lock file
    echo "Not running"   >>${log_file}
    echo $$ > "${lck_file}"
  else
    echo "`basename $0` is already running [${MYPID}]"  >>${log_file}
    echo "`basename $0` is already running [${MYPID}]"
    exit 0
  fi

else
#  echo "Not running"
  echo $$ > "${lck_file}"
fi

echo "*********************************" > ${log_file}
echo "`date`" >> ${log_file}
echo "Main process started : $PID" >>${log_file}

restartminim() {
        while true; do
                if [ -e "$ino_lck_file" ] ; then
                        if test `find "$ino_lck_file" -mmin +1`
                        then
                                echo "Restarting minim at `date`" >>${log_file}
                                $pdir/restartminim.exp 2>&1 >>${log_file}
                                rm $ino_lck_file
                        fi
                fi
                sleep 30
        done
}

myinotifywait() {
        while eval inotifywait -q -r -e close_write,move,delete $watch_dir >>${log_file}; do
                touch $ino_lck_file
        done
}

myinotifywait&
pid1=$!
echo "Myinotifywait spawned: $pid1" >>${log_file}

restartminim&
pid2=$!
echo "Restartminim spawned : $pid2" >>${log_file}

# Kill all sub-processes
trap "kill 0" SIGINT SIGTERM EXIT
wait

echo "finish." >>${log_file}

the config file has just one line/variable:
Code:
watch_dir="/media/upnp"
Find all posts by this user
Quote this message in a reply
23-12-2012, 18:49
Post: #15
RE: Feature Request: Re-Scan/inotify
Im runnin a synology nas ...
where do i have to put this script so it is working?
Find all posts by this user
Quote this message in a reply
24-12-2012, 10:34
Post: #16
RE: Feature Request: Re-Scan/inotify
(23-12-2012 18:49)alegend Wrote:  Im runnin a synology nas ...
where do i have to put this script so it is working?
Hi, unfortunately, this is not an easy task. A challenge might be to compile and install inotify-tools.
I will look into it and maybe make a separate package to automate the necessary steps for Synology DS's.
Find all posts by this user
Quote this message in a reply
24-12-2012, 13:18
Post: #17
RE: Feature Request: Re-Scan/inotify
This would be really great!
Because otherwise I always have to use my comp to update the database.
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)