forked from mtusi2026/mtusi2026lab5
lab5
This commit is contained in:
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
: "${ATTACHMENT_ID:?Set ATTACHMENT_ID to the failed attachment UUID}"
|
||||
|
||||
# Explicit operator action: only a failed job is moved back to the durable queue.
|
||||
docker compose --env-file .env exec -T postgres psql -U "${POSTGRES_USER:-messenger}" -d "${POSTGRES_DB:-messenger}" -v ON_ERROR_STOP=1 \
|
||||
-v attachment_id="$ATTACHMENT_ID" <<'SQL'
|
||||
UPDATE attachment_jobs
|
||||
SET status = 'queued', attempt = 0, next_attempt_at = now(), lease_until = NULL,
|
||||
published_at = NULL, error_code = NULL, updated_at = now()
|
||||
WHERE attachment_id = :'attachment_id' AND status = 'failed';
|
||||
UPDATE attachments
|
||||
SET status = 'queued', error_code = NULL, updated_at = now()
|
||||
WHERE id = :'attachment_id' AND status = 'failed';
|
||||
SQL
|
||||
Executable
+5
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
# Restart API replicas and shared stores without removing named volumes.
|
||||
docker compose --env-file .env restart api worker postgres redis minio lb
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
# Restart one API container at a time and wait for its healthcheck.
|
||||
for container in $(docker compose --env-file .env ps -q api); do
|
||||
docker restart "$container" >/dev/null
|
||||
deadline=$(( $(date +%s) + 60 ))
|
||||
while :; do
|
||||
status=$(docker inspect --format '{{.State.Health.Status}}' "$container" 2>/dev/null || true)
|
||||
[ "$status" = "healthy" ] && break
|
||||
[ "$(date +%s)" -lt "$deadline" ] || exit 1
|
||||
sleep 1
|
||||
done
|
||||
done
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
: "${TARGET_INSTANCE_ID:?TARGET_INSTANCE_ID is required}"
|
||||
|
||||
for container in $(docker compose --env-file .env ps -q api); do
|
||||
hostname=$(docker inspect --format '{{.Config.Hostname}}' "$container")
|
||||
if [ "$hostname" = "$TARGET_INSTANCE_ID" ]; then
|
||||
docker stop "$container" >/dev/null
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
|
||||
exit 2
|
||||
Reference in New Issue
Block a user