mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-09-29 12:39:05 -05:00
fix(host): stop forcing compose -T so operator logs stream live
podman-compose and docker compose allocate a pseudo-TTY by default; always passing -T block-buffered export progress. Omit -T for operator runs and set DCE_COMPOSE_TTY=0 only for cron log append. Adds compose TTY smokes and cron job env assertion.
This commit is contained in:
@@ -103,6 +103,24 @@ run_host() {
|
||||
"$REPO_ROOT/scripts/run-discord-scrape-host.sh" scrape --target demo
|
||||
}
|
||||
|
||||
run_host_compose_capture() {
|
||||
local env_path=${1:-$ENV_FILE}
|
||||
local compose_bin=$2
|
||||
local args_log=$3
|
||||
shift 3
|
||||
local -a extra_env=( "$@" )
|
||||
|
||||
env -u DISCORD_TOKEN \
|
||||
DCE_SKIP_SCRAPE_LOCK=1 \
|
||||
DCE_COMPOSE_BIN="$compose_bin" \
|
||||
DCE_REPO_ROOT="$REPO_ROOT" \
|
||||
DCE_ENV_FILE="$env_path" \
|
||||
DCE_COMPOSE_FILE="$COMPOSE_FILE" \
|
||||
FAKE_COMPOSE_ARGS_LOG="$args_log" \
|
||||
"${extra_env[@]}" \
|
||||
"$REPO_ROOT/scripts/run-discord-scrape-host.sh" scrape --target demo
|
||||
}
|
||||
|
||||
run_host_with_shell_token() {
|
||||
local mode=$1
|
||||
local missing_env_path=$2
|
||||
@@ -173,4 +191,33 @@ grep -q streaming-line2 "$STREAM_OUTPUT" || {
|
||||
exit 1
|
||||
}
|
||||
|
||||
COMPOSE_TTY_LOG="$TMP_DIR/compose-tty-default.log"
|
||||
FAKE_COMPOSE="$TMP_DIR/fake-compose"
|
||||
cat >"$FAKE_COMPOSE" <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
printf '%s\n' "$*" >>"${FAKE_COMPOSE_ARGS_LOG:?}"
|
||||
printf 'run succeeded\n'
|
||||
EOF
|
||||
chmod +x "$FAKE_COMPOSE"
|
||||
|
||||
run_host_compose_capture "$ENV_FILE" "$FAKE_COMPOSE" "$COMPOSE_TTY_LOG" >/dev/null
|
||||
grep -q ' run --rm ' "$COMPOSE_TTY_LOG" || {
|
||||
echo "expected default compose run to omit -T for live TTY allocation" >&2
|
||||
cat "$COMPOSE_TTY_LOG" >&2
|
||||
exit 1
|
||||
}
|
||||
grep -qE '(^|[[:space:]])-T([[:space:]]|$)' "$COMPOSE_TTY_LOG" && {
|
||||
echo "expected default compose run not to pass -T" >&2
|
||||
cat "$COMPOSE_TTY_LOG" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
COMPOSE_NOTTY_LOG="$TMP_DIR/compose-tty-off.log"
|
||||
run_host_compose_capture "$ENV_FILE" "$FAKE_COMPOSE" "$COMPOSE_NOTTY_LOG" DCE_COMPOSE_TTY=0 >/dev/null
|
||||
grep -qE '(^|[[:space:]])-T([[:space:]]|$)' "$COMPOSE_NOTTY_LOG" || {
|
||||
echo "expected DCE_COMPOSE_TTY=0 compose run to use -T" >&2
|
||||
cat "$COMPOSE_NOTTY_LOG" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
echo "run-discord-scrape-host smoke test passed"
|
||||
|
||||
@@ -86,6 +86,7 @@ grep -q '^MAILTO=test@example.com$' "$CRONTAB_FILE" || { echo "expected unrelate
|
||||
[[ "$(grep -c '^# BEGIN discord-scrape$' "$CRONTAB_FILE")" == "1" ]] || { echo "expected exactly one managed cron block after install" >&2; exit 1; }
|
||||
grep -q 'compose --env-file' "$DOCKER_LOG" || { echo "expected docker preflight to run during install" >&2; exit 1; }
|
||||
grep -q 'scripts/run-discord-scrape-host.sh' "$CRONTAB_FILE" || { echo "expected cron job to run host wrapper" >&2; exit 1; }
|
||||
grep -q 'DCE_COMPOSE_TTY=0' "$CRONTAB_FILE" || { echo "expected cron job to disable compose TTY for log append" >&2; exit 1; }
|
||||
|
||||
run_setup
|
||||
[[ "$(grep -c '^# BEGIN discord-scrape$' "$CRONTAB_FILE")" == "1" ]] || { echo "expected exactly one managed cron block after reinstall" >&2; exit 1; }
|
||||
|
||||
Reference in New Issue
Block a user