Fix in the algorithms-updater the check for a already running instance.

This commit is contained in:
Andrea Dell'Amico 2018-04-26 15:51:35 +02:00
parent b0d65d4a17
commit 0e6d107a50
1 changed files with 7 additions and 9 deletions

View File

@ -23,7 +23,6 @@ SVN_UPDATE_STATUS=
UPDATER_PROCESS_MAX_RUNTIME=21600
OLDPROC=
OLDPROC_RUNNING=
RUNNING_JOB_RETVAL=
trap "logger 'algorithms-updater: trap intercepted, exiting.' ; cleanup 1" SIGHUP SIGINT SIGTERM
@ -46,23 +45,22 @@ create_log_dir() {
set +o pipefail
set +e
OLDPROC=$( cat "$LOCK_FILE" )
OLDPROC_RUNNING=$( ps auwwx | grep -v grep | grep $OLDPROC | awk '{ print $2 }' )
RUNNING_JOB_RETVAL=$?
OLDPROC_RUNNING=$( ps auwwx | grep -v grep | awk '{ print $2 }' | grep "$OLDPROC" )
if [ ! -z "$OLDPROC_RUNNING" ] ; then
logger "algorithms_updater: pid of the already running process: $OLDPROC_RUNNING"
OLDPROC_RUNNING_TIME=$( ps -o etimes= -p ${OLDPROC_RUNNING} )
if [ $OLDPROC_RUNNING_TIME -gt $UPDATER_PROCESS_MAX_RUNTIME ] ; then
OLDPROC_RUNNING_TIME=$( ps -o etimes= -p "${OLDPROC_RUNNING}" )
if [ "$OLDPROC_RUNNING_TIME" -gt $UPDATER_PROCESS_MAX_RUNTIME ] ; then
logger "algorithms_updater: process $OLDPROC_RUNNING was running for $OLDPROC_RUNNING_TIME seconds. Got stuck, killing it"
kill -9 $OLDPROC_RUNNING
rm -f $LOCK_FILE
kill -9 "$OLDPROC_RUNNING"
rm -f "$LOCK_FILE"
else
logger "algorithms_updater: another process is running, exiting."
rm -fr $OUT_DIR
rm -fr "$OUT_DIR"
exit 0
fi
else
logger "algorithms_updater: lock file exist but the process not. Continuing."
rm -f $LOCK_FILE
rm -f "$LOCK_FILE"
fi
else
logger 'algorithms-updater: no other jobs running, proceeding.'