fix: ожидание PostgreSQL при старте, скрипт fix-db-connection

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
shop
2026-05-17 09:38:03 +03:00
parent 20987ad793
commit 8dae5d37fc
5 changed files with 110 additions and 8 deletions
+4 -3
View File
@@ -1,6 +1,7 @@
[Unit]
Description=Shop Node.js
After=network.target
After=network.target postgresql.service
Wants=postgresql.service
[Service]
Type=simple
@@ -8,12 +9,12 @@ User=www-data
Group=www-data
WorkingDirectory=/opt/shop
EnvironmentFile=/opt/shop/.env
# Путь к node: which node (часто /usr/bin/node)
# Дождаться PostgreSQL (запуск от root, +)
ExecStartPre=+/bin/bash -c 'for i in $(seq 1 60); do pg_isready -h 127.0.0.1 -p 5432 -q && exit 0; sleep 1; done; echo "PostgreSQL не отвечает на 127.0.0.1:5432"; exit 1'
ExecStart=/usr/bin/node src/server.js
Restart=on-failure
RestartSec=5
# Права на запись в data/ и node_modules (если нужно)
UMask=0022
[Install]