docs: Server-Operations — универсальное развёртывание без привязки к домену
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
Подробности релиза: [CHANGELOG.md](CHANGELOG.md) · [docs/RELEASE-0.20.md](docs/RELEASE-0.20.md)
|
||||
|
||||
**Wiki (установка):** https://git.evilfox.cc/test/shop10/wiki
|
||||
**Сервер (установка, обновление, ошибки):** [wiki/Server-Operations.md](wiki/Server-Operations.md) · [wiki/Troubleshooting.md](wiki/Troubleshooting.md)
|
||||
|
||||
## Возможности
|
||||
|
||||
@@ -100,7 +100,7 @@ apt install -y postgresql-17 postgresql-client-17
|
||||
Пользователь и база `shop`:
|
||||
|
||||
```bash
|
||||
cd /opt/shop/shop10
|
||||
cd "$SHOP_ROOT"
|
||||
bash scripts/setup-postgres-ubuntu.sh
|
||||
```
|
||||
|
||||
@@ -112,34 +112,27 @@ bash scripts/setup-postgres-ubuntu.sh
|
||||
|
||||
## Быстрый развёртывание на Ubuntu
|
||||
|
||||
**Одной командой** (клон в `/opt/shop/shop10`, PostgreSQL через PGDG, systemd):
|
||||
Подставьте **URL своего репозитория** и каталог клона `SHOP_ROOT` (часто `/opt/shop`):
|
||||
|
||||
```bash
|
||||
export SHOP_ROOT=/opt/shop
|
||||
export SHOP_GIT_URL='https://ваш-forge/пользователь/shop.git'
|
||||
|
||||
apt update && apt install -y git curl
|
||||
git clone https://git.evilfox.cc/test/shop10.git /opt/shop/shop10
|
||||
cd /opt/shop/shop10
|
||||
sudo bash scripts/quick-deploy-ubuntu.sh
|
||||
git clone "$SHOP_GIT_URL" "$SHOP_ROOT"
|
||||
cd "$SHOP_ROOT"
|
||||
sudo SHOP_INSTALL_DIR="$SHOP_ROOT" SHOP_GIT_URL="$SHOP_GIT_URL" bash scripts/quick-deploy-ubuntu.sh
|
||||
```
|
||||
|
||||
**Уже установлен магазин — только обновить код:**
|
||||
**Обновление** (сайт уже работает):
|
||||
|
||||
```bash
|
||||
bash /opt/shop/shop10/scripts/server-update.sh
|
||||
bash "$SHOP_ROOT/scripts/server-update.sh"
|
||||
```
|
||||
|
||||
Не выполняйте `cd /opt/shop`, если репозиторий в `/opt/shop/shop10` — там нет `package.json`.
|
||||
Не копируйте в shell шаблоны вроде `<URL_РЕПОЗИТОРИЯ>` — это подсказки в тексте, не команды.
|
||||
|
||||
Ручная установка:
|
||||
|
||||
```bash
|
||||
cd /opt/shop/shop10
|
||||
sudo bash scripts/install-postgresql-ubuntu.sh # PGDG, не apt install postgresql-17 напрямую
|
||||
bash scripts/setup-postgres-ubuntu.sh
|
||||
cp .env.example .env
|
||||
# SESSION_SECRET, DATABASE_URL, SITE_URL
|
||||
npm install --omit=dev
|
||||
systemctl restart shop
|
||||
```
|
||||
Подробно: **[wiki/Server-Operations.md](wiki/Server-Operations.md)** (PostgreSQL PGDG, git, systemd, порт 3000).
|
||||
|
||||
Проверка:
|
||||
|
||||
@@ -170,7 +163,7 @@ DATABASE_URL=postgresql://shop:shop@127.0.0.1:5432/shop
|
||||
## Запуск как служба (systemd)
|
||||
|
||||
```bash
|
||||
cd /opt/shop/shop10
|
||||
cd "$SHOP_ROOT"
|
||||
cp .env.example .env # при первой установке — SESSION_SECRET, DATABASE_URL
|
||||
sudo bash scripts/install-shop-service.sh
|
||||
journalctl -u shop -f
|
||||
@@ -178,7 +171,7 @@ journalctl -u shop -f
|
||||
|
||||
Не делайте `chown -R www-data` на весь каталог репозитория (ломает `git pull`).
|
||||
|
||||
`EnvironmentFile=/opt/shop/shop10/.env` должен содержать `DATABASE_URL`.
|
||||
`EnvironmentFile` в unit должен указывать на `$SHOP_ROOT/.env` с `DATABASE_URL`.
|
||||
|
||||
---
|
||||
|
||||
@@ -197,28 +190,23 @@ journalctl -u shop -n 5 --no-pager
|
||||
|
||||
## Обновление на сервере (git pull)
|
||||
|
||||
Каталог клона — там, где лежат `package.json` и `scripts/` (часто `/opt/shop` или `/opt/shop/shop10`):
|
||||
См. **[wiki/Server-Operations.md](wiki/Server-Operations.md)**.
|
||||
|
||||
```bash
|
||||
cd /opt/shop/shop10
|
||||
bash scripts/git-sync.sh # если detached HEAD или ошибка git pull
|
||||
export SHOP_ROOT=/opt/shop
|
||||
cd "$SHOP_ROOT"
|
||||
bash scripts/git-sync.sh # если detached HEAD
|
||||
bash scripts/server-update.sh
|
||||
```
|
||||
|
||||
Или одной командой (путь к скрипту в вашем клоне):
|
||||
|
||||
```bash
|
||||
bash /opt/shop/shop10/scripts/server-update.sh
|
||||
```
|
||||
|
||||
Скрипт сам найдёт корень репозитория. В `deploy/shop.service` поле `WorkingDirectory` должно указывать на тот же каталог.
|
||||
`WorkingDirectory` в `deploy/shop.service` = ваш `$SHOP_ROOT`.
|
||||
|
||||
Скрипт: `git pull` → `npm install` → проверка PostgreSQL → `restart shop` → `curl /health` → `reload caddy`.
|
||||
|
||||
Вручную:
|
||||
|
||||
```bash
|
||||
cd /opt/shop/shop10
|
||||
cd "$SHOP_ROOT"
|
||||
git pull
|
||||
npm install --omit=dev
|
||||
systemctl restart shop
|
||||
@@ -270,13 +258,13 @@ shop.example.com {
|
||||
**Быстрое исправление (одной командой):**
|
||||
|
||||
```bash
|
||||
bash /opt/shop/shop10/scripts/fix-db-connection.sh
|
||||
bash "$SHOP_ROOT/scripts/fix-db-connection.sh"
|
||||
```
|
||||
|
||||
**Вручную:**
|
||||
|
||||
```bash
|
||||
cd /opt/shop/shop10
|
||||
cd "$SHOP_ROOT"
|
||||
sudo bash scripts/install-postgresql-ubuntu.sh
|
||||
systemctl enable --now postgresql
|
||||
pg_isready -h 127.0.0.1 -p 5432
|
||||
@@ -293,7 +281,7 @@ curl -s http://127.0.0.1:3000/health
|
||||
### HTTP 502
|
||||
|
||||
```bash
|
||||
bash /opt/shop/shop10/scripts/diagnose-502.sh
|
||||
bash "$SHOP_ROOT/scripts/diagnose-502.sh"
|
||||
journalctl -u shop -n 50 --no-pager
|
||||
```
|
||||
|
||||
@@ -347,8 +335,8 @@ src/
|
||||
## Релиз 0.20.0
|
||||
|
||||
```bash
|
||||
git clone https://git.evilfox.cc/test/shop10.git /opt/shop/shop10
|
||||
cd /opt/shop/shop10
|
||||
git clone <URL-вашего-репозитория> /opt/shop
|
||||
cd /opt/shop
|
||||
git checkout v0.20.0
|
||||
```
|
||||
|
||||
@@ -360,6 +348,6 @@ git checkout v0.20.0
|
||||
## Репозиторий
|
||||
|
||||
```bash
|
||||
git clone https://git.evilfox.cc/test/shop10.git /opt/shop/shop10
|
||||
cd /opt/shop/shop10
|
||||
git clone <URL-вашего-репозитория> /opt/shop
|
||||
cd /opt/shop
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user