fix: 添加PostgreSQL启动超时处理
This commit is contained in:
parent
809ff9428c
commit
0e252281cd
18
deploy.sh
18
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
|
||||
|
|
|
|||
Loading…
Reference in New Issue