Download scripts/dev-agy.sh from a3216/ds2api: direct link, hf CLI and curl.
- Browser
- Download file 1.55 kB
-
https://huggingface.co/spaces/a3216/ds2api/resolve/main/scripts/dev-agy.sh
- Command line
-
hf download hf://spaces/a3216/ds2api/scripts/dev-agy.sh
-
curl -L -o dev-agy.sh https://huggingface.co/spaces/a3216/ds2api/resolve/main/scripts/dev-agy.sh
1.55 kB
| # 本地开发用:创建 venv、安装依赖并启动内嵌 agy2api 旁车。 | |
| # 生产环境由 entrypoint.sh 在容器内启动,不需要该脚本。 | |
| set -euo pipefail | |
| ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)" | |
| AGY_DIR="${ROOT_DIR}/agy2api" | |
| VENV_DIR="${AGY_VENV_DIR:-${AGY_DIR}/.venv}" | |
| if [ ! -f "${AGY_DIR}/web.py" ]; then | |
| echo "agy2api source not found at ${AGY_DIR}" >&2 | |
| exit 1 | |
| fi | |
| if [ ! -x "${VENV_DIR}/bin/python" ]; then | |
| PYTHON_BIN="${PYTHON_BIN:-python3}" | |
| if ! command -v "${PYTHON_BIN}" >/dev/null 2>&1; then | |
| echo "python3 is required to run the agy2api sidecar" >&2 | |
| exit 1 | |
| fi | |
| echo "creating virtualenv at ${VENV_DIR}" | |
| "${PYTHON_BIN}" -m venv "${VENV_DIR}" | |
| fi | |
| if ! "${VENV_DIR}/bin/python" -c 'import sys; raise SystemExit(0 if sys.version_info >= (3, 12) else 1)'; then | |
| echo "agy2api requires Python 3.12+" >&2 | |
| exit 1 | |
| fi | |
| echo "installing agy2api dependencies" | |
| "${VENV_DIR}/bin/python" -m pip install --quiet --disable-pip-version-check -r "${AGY_DIR}/requirements.txt" | |
| export HOST="${AGY2API_HOST:-127.0.0.1}" | |
| export PORT="${AGY2API_PORT:-7861}" | |
| export PATH_PREFIX="${AGY2API_PATH_PREFIX:-/agy}" | |
| export API_PASSWORD="${AGY2API_API_PASSWORD:-${DS2API_ADMIN_KEY:-pwd}}" | |
| export PANEL_PASSWORD="${AGY2API_PANEL_PASSWORD:-${API_PASSWORD}}" | |
| export CREDENTIALS_DIR="${AGY2API_CREDENTIALS_DIR:-${AGY_DIR}/creds}" | |
| export LOG_LEVEL="${AGY2API_LOG_LEVEL:-INFO}" | |
| echo "starting agy2api sidecar on ${HOST}:${PORT} (PATH_PREFIX=${PATH_PREFIX})" | |
| cd "${AGY_DIR}" | |
| exec "${VENV_DIR}/bin/python" web.py | |