fix: быстрое развёртывание — PGDG, /opt/shop/shop10, без placeholder URL

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
shop
2026-05-17 13:23:00 +03:00
parent 42177555ac
commit b7c8d2ed80
9 changed files with 238 additions and 86 deletions
+15 -14
View File
@@ -2,29 +2,30 @@
# Быстрое исправление ECONNREFUSED 127.0.0.1:5432
set -euo pipefail
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/shop-root.sh"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/shop-root.sh"
echo "=== Исправление подключения к PostgreSQL ==="
echo "=== Исправление подключения к PostgreSQL ($SHOP_ROOT) ==="
if ! dpkg -l | grep -q postgresql; then
echo "Установка PostgreSQL 17..."
apt update
apt install -y postgresql-17 postgresql-client-17 || {
echo "Если пакет не найден — см. README (репозиторий PGDG)"
exit 1
}
if ! command -v psql >/dev/null; then
bash "$SCRIPT_DIR/install-postgresql-ubuntu.sh"
fi
bash scripts/setup-postgres-ubuntu.sh
bash "$SCRIPT_DIR/setup-postgres-ubuntu.sh"
if [ -f .env ] && ! grep -q '^DATABASE_URL=' .env; then
echo "DATABASE_URL=postgresql://shop:shop@127.0.0.1:5432/shop" >> .env
echo 'DATABASE_URL=postgresql://shop:shop@127.0.0.1:5432/shop' >> .env
echo "Добавлен DATABASE_URL в .env"
fi
cp -f deploy/shop.service /etc/systemd/system/shop.service
systemctl daemon-reload
systemctl restart shop
if [ -f deploy/shop.service ]; then
cp -f deploy/shop.service /etc/systemd/system/shop.service
sed -i "s|WorkingDirectory=.*|WorkingDirectory=${SHOP_ROOT}|" /etc/systemd/system/shop.service
sed -i "s|EnvironmentFile=.*|EnvironmentFile=${SHOP_ROOT}/.env|" /etc/systemd/system/shop.service
systemctl daemon-reload
fi
systemctl restart shop 2>/dev/null || true
sleep 2
if curl -sf http://127.0.0.1:3000/health; then