From 0e252281cdebb35f705ea67632f5dcd8a15785ab Mon Sep 17 00:00:00 2001 From: lgh <625458956@qq.com> Date: Fri, 20 Feb 2026 23:18:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0PostgreSQL=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E8=B6=85=E6=97=B6=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy.sh | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/deploy.sh b/deploy.sh index 3740af1..42ed8c3 100644 --- a/deploy.sh +++ b/deploy.sh @@ -88,9 +88,23 @@ echo -e "${YELLOW}[2/9] 配置 PostgreSQL 数据库...${NC}" apt-get install -y --no-install-recommends postgresql postgresql-contrib || true -systemctl start postgresql -systemctl enable postgresql +# 启动 PostgreSQL +echo "启动 PostgreSQL..." +systemctl start postgresql || true +systemctl enable postgresql || true +# 等待 PostgreSQL 就绪 (最多等待 30 秒) +echo "等待 PostgreSQL 就绪..." +for i in {1..30}; do + if su - postgres -c "psql -c 'SELECT 1;'" > /dev/null 2>&1; then + echo "PostgreSQL 已就绪" + break + fi + sleep 1 +done + +# 创建数据库 +echo "创建数据库..." su - postgres -c "psql -c \"CREATE DATABASE neural_sync;\"" 2>/dev/null || true su - postgres -c "psql -c \"CREATE USER neuraluser WITH PASSWORD '$DB_PASSWORD';\"" 2>/dev/null || true su - postgres -c "psql -c \"GRANT ALL PRIVILEGES ON DATABASE neural_sync TO neuraluser;\"" 2>/dev/null || true