mirror of
https://github.com/arc53/DocsGPT.git
synced 2026-05-16 18:22:16 +00:00
* feat: postgres tests * feat: mongo cutoff * feat: mongo cutoff * feat: adjust docs and compose files * fix: mini code mongo removals * fix: tests and k8s mongo stuff * feat: test fixes * fix: ruff * fix: vale * Potential fix for pull request finding 'CodeQL / Clear-text logging of sensitive information' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> * fix: mini suggestions * vale lint fix 2 * fix: codeql columns thing * fix: test mongo * fix: tests coverage * feat: better tests 4 * feat: more tests * feat: decent coverage * fix: ruff fixes * fix: remove mongo mock * feat: enhance workflow engine and API routes; add document retrieval and source handling * feat: e2e tests * fix: mcp, mongo and more * fix: mini codeql warning * fix: agent chunk view * fix: mini issues * fix: more pg fixes * feat: postgres prep on start * feat: qa tests * fix: mini improvements * fix: tests --------- Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Co-authored-by: Siddhant Rai <siddhant.rai.5686@gmail.com>
96 lines
2.3 KiB
Bash
Executable File
96 lines
2.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# scripts/e2e/down.sh
|
|
#
|
|
# Tear down the DocsGPT end-to-end test stack started by up.sh.
|
|
# Reads pidfiles from /tmp/docsgpt-e2e/*.pid, sends SIGTERM, waits up to 3s,
|
|
# escalates to SIGKILL if still alive, removes each pidfile.
|
|
#
|
|
# Constraints:
|
|
# - Idempotent: exits 0 even when no pidfiles exist.
|
|
# - NEVER uses pkill/killall (CLAUDE.md: don't risk killing native
|
|
# Postgres/Redis/Mongo processes).
|
|
# - NEVER touches shared DB/Redis services.
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
|
|
PIDDIR="/tmp/docsgpt-e2e"
|
|
|
|
log() {
|
|
echo "[down.sh] $*" >&2
|
|
}
|
|
|
|
# Stop a single service given its pidfile. Best-effort; never fatal.
|
|
stop_one() {
|
|
local pidfile="$1"
|
|
local svc
|
|
svc="$(basename "$pidfile" .pid)"
|
|
|
|
if [[ ! -s "$pidfile" ]]; then
|
|
log "$svc: pidfile empty or missing — removing"
|
|
rm -f "$pidfile"
|
|
return 0
|
|
fi
|
|
|
|
local pid
|
|
pid="$(cat "$pidfile" 2>/dev/null || true)"
|
|
|
|
# Guard against garbage in the pidfile (non-numeric or empty).
|
|
if ! [[ "$pid" =~ ^[0-9]+$ ]]; then
|
|
log "$svc: pidfile contents not numeric ('$pid') — removing"
|
|
rm -f "$pidfile"
|
|
return 0
|
|
fi
|
|
|
|
if ! kill -0 "$pid" 2>/dev/null; then
|
|
log "$svc: pid $pid not running — removing pidfile"
|
|
rm -f "$pidfile"
|
|
return 0
|
|
fi
|
|
|
|
log "$svc: sending SIGTERM to pid $pid"
|
|
kill "$pid" 2>/dev/null || true
|
|
|
|
# Poll up to 3 seconds for graceful exit.
|
|
local waited=0
|
|
while (( waited < 3 )); do
|
|
if ! kill -0 "$pid" 2>/dev/null; then
|
|
break
|
|
fi
|
|
sleep 1
|
|
waited=$(( waited + 1 ))
|
|
done
|
|
|
|
if kill -0 "$pid" 2>/dev/null; then
|
|
log "$svc: pid $pid still alive after 3s — SIGKILL"
|
|
kill -9 "$pid" 2>/dev/null || true
|
|
else
|
|
log "$svc: pid $pid exited gracefully"
|
|
fi
|
|
|
|
rm -f "$pidfile"
|
|
}
|
|
|
|
if [[ ! -d "$PIDDIR" ]]; then
|
|
log "no pid directory at $PIDDIR — nothing to stop"
|
|
exit 0
|
|
fi
|
|
|
|
shopt -s nullglob
|
|
pidfiles=( "$PIDDIR"/*.pid )
|
|
shopt -u nullglob
|
|
|
|
if (( ${#pidfiles[@]} == 0 )); then
|
|
log "no pidfiles in $PIDDIR — nothing to stop"
|
|
exit 0
|
|
fi
|
|
|
|
for pidfile in "${pidfiles[@]}"; do
|
|
stop_one "$pidfile"
|
|
done
|
|
|
|
log "teardown complete"
|
|
exit 0
|