mirror of
https://github.com/iflytek/skillhub.git
synced 2026-11-14 09:01:16 +00:00
fix: report external receiver status and harden demo shell entry
Signed-off-by: 千乘妍 (Xiaoyaner) <xiaoyaner0201@users.noreply.github.com>
This commit is contained in:
parent
27779a3d05
commit
a904719225
3 changed files with 18 additions and 5 deletions
|
|
@ -4,7 +4,7 @@ set -eu
|
|||
ROOT=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd)
|
||||
STATE_DIR=${BUSINESS_LOGS_DEMO_STATE_DIR:-$ROOT/.dev/business-logs}
|
||||
COMMAND=${1:-status}
|
||||
shift || true
|
||||
[ "$#" -eq 0 ] || shift
|
||||
|
||||
if [ "$COMMAND" = run-host ]; then
|
||||
if [ -f "$STATE_DIR/host-port" ]; then
|
||||
|
|
|
|||
|
|
@ -146,7 +146,8 @@ Business Logs (default off):
|
|||
business-logs-enable Apply .env.release to server; --logs-endpoint overrides receiver
|
||||
business-logs-disable Disable collection and recreate server; keep receiver and data
|
||||
business-logs-down Stop only the optional Collector; keep files and network
|
||||
business-logs-ps/logs Inspect only the optional Collector
|
||||
business-logs-ps Show collection state and optional Collector status
|
||||
business-logs-logs Follow optional Collector logs
|
||||
--logs-endpoint <url> Full OTLP/HTTP Logs URL (no credentials/query/fragment)
|
||||
--logs-network <name> Attach server to this external private network
|
||||
|
||||
|
|
@ -513,7 +514,7 @@ validate_business_logs_endpoint() {
|
|||
*) echo "Business Logs requires a full HTTP(S) Logs URL" >&2; exit 1 ;;
|
||||
esac
|
||||
case "$1" in
|
||||
*'@'*|*'?'*|*'#'*|*[[:space:]]*|*'\\'*)
|
||||
*'@'*|*'?'*|*'#'*|*[[:space:]]*|*'\'*)
|
||||
echo "Business Logs URL must not contain credentials, query, fragment or whitespace" >&2; exit 1 ;;
|
||||
esac
|
||||
}
|
||||
|
|
@ -777,11 +778,18 @@ EOF
|
|||
run_compose up -d --no-deps --force-recreate server
|
||||
echo "Business Logs disabled; receiver data and network retained."
|
||||
;;
|
||||
business-logs-down|business-logs-ps|business-logs-logs)
|
||||
business-logs-ps)
|
||||
printf 'Business Logs enabled: %s\n' "$(get_env_value SKILLHUB_BUSINESS_LOGS_ENABLED false)"
|
||||
if [ -f "$BUSINESS_LOGS_ENV_FILE" ]; then
|
||||
run_business_logs_compose ps
|
||||
else
|
||||
echo "No optional Collector; the receiver is managed externally."
|
||||
fi
|
||||
;;
|
||||
business-logs-down|business-logs-logs)
|
||||
[ -f "$BUSINESS_LOGS_ENV_FILE" ] || { echo "No optional Collector; run business-logs-up first" >&2; exit 1; }
|
||||
case "$COMMAND" in
|
||||
business-logs-down) run_business_logs_compose stop ;;
|
||||
business-logs-ps) run_business_logs_compose ps ;;
|
||||
business-logs-logs) run_business_logs_compose logs -f ;;
|
||||
esac
|
||||
;;
|
||||
|
|
|
|||
|
|
@ -26,9 +26,13 @@ run up --no-scanner
|
|||
grep -q '^SKILLHUB_BUSINESS_LOGS_ENABLED=false$' "$TMP/home/.env.release" || fail 'not default off'
|
||||
if run business-logs-enable --logs-endpoint 'https://fake:secret@receiver.invalid/v1/logs'; then fail 'credential URL accepted'; fi
|
||||
! grep -q 'fake:secret' "$TMP/output" || fail 'URL leaked'
|
||||
if run business-logs-enable --logs-endpoint 'http://receiver\invalid/v1/logs'; then fail 'backslash URL accepted'; fi
|
||||
run business-logs-enable --logs-endpoint https://receiver.example.com/v1/logs
|
||||
grep -q '^SKILLHUB_BUSINESS_LOGS_ENABLED=true$' "$TMP/home/.env.release" || fail 'existing receiver not enabled'
|
||||
grep -q '^SKILLHUB_BUSINESS_LOGS_NETWORK_ENABLED=false$' "$TMP/home/.env.release" || fail 'public receiver joined network'
|
||||
run business-logs-ps
|
||||
grep -q 'Business Logs enabled: true' "$TMP/output" || fail 'existing receiver status missing'
|
||||
grep -q 'managed externally' "$TMP/output" || fail 'existing receiver status requires Collector'
|
||||
run business-logs-enable --logs-network synthetic-business-logs --logs-endpoint http://existing:4318/v1/logs
|
||||
run up --no-scanner
|
||||
grep -q 'compose.release.business-logs.yml up -d postgres' "$DOCKER_LOG" || fail 'plain up lost network overlay'
|
||||
|
|
@ -59,6 +63,7 @@ run business-logs-up --aliyun
|
|||
[ -f "$TMP/home/business-logs/business-logs-collector.yaml" ] || fail 'flat OSS retrieval failed'
|
||||
|
||||
export BUSINESS_LOGS_DEMO_STATE_DIR="$TMP/state" SKILLHUB_BUSINESS_LOGS_DEMO_PORT=14318
|
||||
sh "$ROOT/scripts/business-logs-demo.sh" >"$TMP/demo-output"
|
||||
sh "$ROOT/scripts/business-logs-demo.sh" up >"$TMP/demo-output"
|
||||
result=$(sh "$ROOT/scripts/business-logs-demo.sh" run-host sh -c 'printf "%s %s" "$SKILLHUB_BUSINESS_LOGS_ENABLED" "$SKILLHUB_BUSINESS_LOGS_ENDPOINT"')
|
||||
[ "$result" = 'true http://127.0.0.1:14318/v1/logs' ] || fail 'host receive address'
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue