Skip to content

Commit 576efa5

Browse files
committed
fix(ops): prevent container name conflict during leaderboard deployment
1 parent 0ccb776 commit 576efa5

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

ops/deploy/deploy-leaderboard.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,19 @@ fi
2929
echo "[1/3] Pulling latest GHCR image..."
3030
docker compose --project-directory "${PROJECT_ROOT}" "${ENV_ARGS[@]}" -f "${COMPOSE_FILE}" pull
3131

32-
# Check if worker container is running and an active calculation is in progress
32+
# Check if worker container exists and an active calculation is in progress
3333
CONTAINER_NAME="devimpact-leaderboard-cron"
34-
if docker ps --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then
34+
if docker ps -a --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then
3535
echo "[2/3] Checking for active leaderboard calculation..."
3636
while docker exec "${CONTAINER_NAME}" pgrep -f "calculate-next-country" > /dev/null 2>&1 || \
37-
docker exec "${CONTAINER_NAME}" sh -c 'ps aux | grep -v grep | grep -q "calculate-next-country"'; do
37+
docker exec "${CONTAINER_NAME}" sh -c 'ps aux | grep -v grep | grep -q "calculate-next-country"' > /dev/null 2>&1; do
3838
echo " >> A leaderboard calculation job is currently running. Waiting for it to finish..."
3939
sleep 10
4040
done
4141
echo " >> No active calculation running (or active calculation completed)."
42+
echo " >> Removing previous container to prevent name conflicts..."
43+
docker stop "${CONTAINER_NAME}" > /dev/null 2>&1 || true
44+
docker rm -f "${CONTAINER_NAME}" > /dev/null 2>&1 || true
4245
else
4346
echo "[2/3] Worker container is not running yet."
4447
fi

ops/docker/leaderboard-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
name: devimpact-leaderboard
2+
13
services:
24
leaderboard-cron:
35
image: ${LEADERBOARD_IMAGE:-ghcr.io/o2sa/devimpact-leaderboard:latest}

0 commit comments

Comments
 (0)