Skip to content

Commit

Permalink
[cleanup-binary] Synchronize after kills
Browse files Browse the repository at this point in the history
  • Loading branch information
kostorr authored and teo committed Jun 9, 2022
1 parent 98fc5bd commit df8aebf
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions cmd/o2-aliecs-shmcleaner
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,39 @@ export O2_ROLE=${O2_ROLE:-}

# ------ Beginning extra cleanup ------
n=0
for p in `pgrep -u flp`; do
pids=$(pgrep -u flp)

# Try to kill any flp-owned processes gracefully
for p in $pids; do
c="`ps -ho %c $p`"
[ "$c" = "o2-alf" ] && continue
echo "Kill '%s' (PID:%s)\n" "`date`" "`hostname -s`" "$c" "$p" | $O2_INFOLOGGER_PATH/bin/o2-infologger-log -x -s Debug -o Facility=$O2_FACILITY -o Partition=$O2_PARTITION
n=$((n+1))
kill $p
done

# Force kill any flp-owned processes remaining
if (( n > 0 )); then

sleep 5

for p in `pgrep -u flp`; do
for p in $pids; do
c="`ps -ho %c $p`"
[ "$c" = "o2-alf" ] && continue
echo "Kill -9 '%s' (PID:%s)\n" "`date`" "`hostname -s`" "$c" "$p" | $O2_INFOLOGGER_PATH/bin/o2-infologger-log -x -s Debug -o Facility=$O2_FACILITY
echo "Kill -9 '%s' (PID:%s)\n" "`date`" "`hostname -s`" "$c" "$p" | $O2_INFOLOGGER_PATH/bin/o2-infologger-log -x -s Debug -o Facility=$O2_FACILITY -o Partition=$O2_PARTITION
kill -9 $p
done
fi

# Ensure that no flp-owned processes remain before returning
if (( n > 0 )); then
for p in $pids; do
while [ kill -0 $p > /dev/null 2>&1]; do
sleep 0.1
done
done
fi

rm -f /dev/shm/*fmq*

yes | roc-cleanup --light > /dev/null 3>&1
Expand Down

0 comments on commit df8aebf

Please sign in to comment.