#!/usr/bin/env bash set -euo pipefail RUN_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" WEBAPP_DIR="${RUN_ROOT}/runtime/webapp" LOG_DIR="${RUN_ROOT}/runtime/logs" PID_FILE="${RUN_ROOT}/runtime/zq-static.pid" LOG_FILE="${LOG_DIR}/zq-static.log" PORT="${ZQ_STATIC_PORT:-4180}" mkdir -p "${LOG_DIR}" if [[ -f "${PID_FILE}" ]]; then pid="$(cat "${PID_FILE}")" if [[ -n "${pid}" ]] && kill -0 "${pid}" 2>/dev/null; then echo "ZQ 静态预览已在运行:http://127.0.0.1:${PORT}/" exit 0 fi rm -f "${PID_FILE}" fi nohup python3 -m http.server "${PORT}" --bind 127.0.0.1 --directory "${WEBAPP_DIR}" > "${LOG_FILE}" 2>&1 & echo $! > "${PID_FILE}" echo "ZQ 静态预览启动中:http://127.0.0.1:${PORT}/"