hyf-backend/scripts/start_local.sh

20 lines
979 B
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 本地启动(不使用 Docker使用本地 PostgreSQL
#
# 前置条件:
# 1. 本地 PostgreSQL 已安装并运行,且已安装 pgvector 扩展
# 2. 已创建数据库 th_agenter、用户 drgraph / 密码 yingping与 docker-compose 一致)
# 创建示例psql -U postgres -c "CREATE USER drgraph WITH PASSWORD 'yingping';"
# psql -U postgres -c "CREATE DATABASE th_agenter OWNER drgraph;"
# psql -U drgraph -d th_agenter -c "CREATE EXTENSION vector;"
# 3. 首次运行前执行迁移DATABASE_URL="postgresql+asyncpg://drgraph:yingping@localhost:5432/th_agenter" python3 -m alembic upgrade head
#
# 也可在 .env 中设置 DATABASE_URL=postgresql+asyncpg://drgraph:yingping@localhost:5432/th_agenter
set -e
cd "$(dirname "$0")/.."
export DATABASE_URL="${DATABASE_URL:-postgresql+asyncpg://drgraph:yingping@localhost:5432/th_agenter}"
exec python3 -m uvicorn main:app --host 0.0.0.0 --port 8000 --reload