Skip to content

Commit

Permalink
Merge pull request #214 from cevich/mac_pw_pool_fix_deadlock
Browse files Browse the repository at this point in the history
Fix deadlock induced MacOS PW Pool collapse
  • Loading branch information
cevich authored Aug 5, 2024
2 parents b0dde0f + 47a5015 commit 13be116
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion mac_pw_pool/nightly_maintenance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,20 @@ if [[ ! -r "$CRONLOG" ]] || [[ ! -r "$CRONSCRIPT" ]] || [[ ! -d "../.git" ]]; th
fi

relaunch_web_container() {
# Assume code has changed, restart container w/ latest image
# Assume code change or image update, restart container.
(
# Prevent podman and/or sub-processes from inheriting the lock FD.
# This would deadlock all future runs of this script or Cron.sh
# Can't use `flock --close ...` here because it "hangs" in this context.
for fd_nr in $(/bin/ls /proc/self/fd/); do
[[ $fd_nr -ge 3 ]] || \
continue
# Bash doesn't allow direct substitution of the FD number
eval "exec $fd_nr>&-"
done

set -x

podman run --replace --name "$_CNTNAME" -d --rm --pull=newer -p 8080:80 \
-v $HOME/devel/automation/mac_pw_pool/html:/usr/share/nginx/html:ro,Z \
$WEB_IMG
Expand Down

0 comments on commit 13be116

Please sign in to comment.