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